diff options
| author | Fijxu <fijxu@nadeko.net> | 2025-05-09 02:58:29 -0400 |
|---|---|---|
| committer | Fijxu <fijxu@nadeko.net> | 2025-05-09 02:58:29 -0400 |
| commit | b120abdcc550060fc414390c7c06a879f3bea348 (patch) | |
| tree | 6bab6b0d45ccb9bc82261eecf1d24c619b44ba28 /src | |
| parent | d1bc15b8bffe7afad6000208dfe2cbd5601b4786 (diff) | |
| download | invidious-b120abdcc550060fc414390c7c06a879f3bea348.tar.gz invidious-b120abdcc550060fc414390c7c06a879f3bea348.tar.bz2 invidious-b120abdcc550060fc414390c7c06a879f3bea348.zip | |
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="}
```
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/yt_backend/extractors.cr | 2 |
1 files changed, 1 insertions, 1 deletions
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" |
