mirror of
https://github.com/iv-org/invidious.git
synced 2025-05-24 09:01:27 -04:00
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="} ```
This commit is contained in:
parent
d1bc15b8bf
commit
b120abdcc5
1 changed files with 1 additions and 1 deletions
|
@ -115,7 +115,7 @@ private module Parsers
|
||||||
badges = VideoBadges::None
|
badges = VideoBadges::None
|
||||||
item_contents["badges"]?.try &.as_a.each do |badge|
|
item_contents["badges"]?.try &.as_a.each do |badge|
|
||||||
b = badge["metadataBadgeRenderer"]
|
b = badge["metadataBadgeRenderer"]
|
||||||
case b["label"].as_s
|
case b["label"]?.try &.as_s
|
||||||
when "LIVE"
|
when "LIVE"
|
||||||
badges |= VideoBadges::LiveNow
|
badges |= VideoBadges::LiveNow
|
||||||
when "New"
|
when "New"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue