From b120abdcc550060fc414390c7c06a879f3bea348 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Fri, 9 May 2025 02:58:29 -0400 Subject: [PATCH] fix: safely access "label" key Fixes https://github.com/iv-org/invidious/issues/5095 On some videos, `label` is missing from the video information. Invidious assumed that the `label` key existed. Videos with label have this inside `metadataBadgeRenderer`: ``` {"style" => "BADGE_STYLE_TYPE_SIMPLE", "label" => "4K", "trackingParams" => "COMDENwwGAoiEwiCrebe6JWNAxWIxz8EHSQRFTU="} ``` but other videos, for some reason, look like this: ``` {"icon" => {"iconType" => "PERSON_RADAR"}, "style" => "BADGE_STYLE_TYPE_SIMPLE", "trackingParams" => "CM4DENwwGAsiEwiCrebe6JWNAxWIxz8EHSQRFTU="} ``` --- src/invidious/yt_backend/extractors.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index edd7bf1b..b78f01c6 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -115,7 +115,7 @@ private module Parsers badges = VideoBadges::None item_contents["badges"]?.try &.as_a.each do |badge| b = badge["metadataBadgeRenderer"] - case b["label"].as_s + case b["label"]?.try &.as_s when "LIVE" badges |= VideoBadges::LiveNow when "New"