Skip to content

Commit b120abd

Browse files
committed
fix: safely access "label" key
Fixes #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="} ```
1 parent d1bc15b commit b120abd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/invidious/yt_backend/extractors.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private module Parsers
115115
badges = VideoBadges::None
116116
item_contents["badges"]?.try &.as_a.each do |badge|
117117
b = badge["metadataBadgeRenderer"]
118-
case b["label"].as_s
118+
case b["label"]?.try &.as_s
119119
when "LIVE"
120120
badges |= VideoBadges::LiveNow
121121
when "New"

0 commit comments

Comments
 (0)