-
-
Notifications
You must be signed in to change notification settings - Fork 2k
yt: Detect Mix playlists robustly and avoid '-1 videos' overlay (Fixes #5454) #5477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
yt: Detect Mix playlists robustly and avoid '-1 videos' overlay (Fixes #5454) #5477
Conversation
…LockupViewModelParser: detect MIX icon at any index, case-insensitive 'Mix' text, RD- prefixed fallback; robust digit extraction for video_count.\n- GridPlaylistRendererParser/PlaylistRendererParser: set is_mix based on RD prefix.\n- SearchPlaylist: add is_mix field (ignored by DB).\n- locales(en-US): add label_mix.\n\nFixes: iv-org#5454
I'm wondering: Did you use an AI tool to write this ? |
@SamantazFox I use Copilot to create PR. |
@naoNao89 whats a "Compitol" ? |
It's copilot with a typo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where the frontend (HTML) code is using the new is_mix
property. Did you forget to push a commit?
"preferences_default_playlist": "Default playlist: ", | ||
"preferences_default_playlist_none": "No default playlist set", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make unrelated changes.
# This complicated sequences tries to extract the following data structure: | ||
# "overlays": [{ | ||
# "thumbnailOverlayBadgeViewModel": { | ||
# "thumbnailBadges": [{ | ||
# "thumbnailBadgeViewModel": { | ||
# "text": "430 episodes", | ||
# "badgeStyle": "THUMBNAIL_OVERLAY_BADGE_STYLE_DEFAULT" | ||
# } | ||
# }] | ||
# } | ||
# }] | ||
# | ||
# NOTE: this simplistic `.to_i` conversion might not work on larger | ||
# playlists and hasn't been tested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider adapting the comment instead of entirely removing it
# Detect Mix playlists via icon imageName at any index or text case-insensitively | ||
is_mix = overlays.any? { |badge| | ||
sources = badge.dig?("thumbnailBadgeViewModel", "icon", "sources").try &.as_a || [] of JSON::Any | ||
has_mix_icon = sources.any? { |s| s.dig?("clientResource", "imageName").try &.as_s == "MIX" } | ||
text = badge.dig?("thumbnailBadgeViewModel", "text").try &.as_s || "" | ||
has_mix_text = text.downcase == "mix" | ||
has_mix_icon || has_mix_text | ||
} | ||
|
||
# Fallback: RD-prefixed playlist IDs are Mixes | ||
is_mix ||= playlist_id.starts_with? "RD" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to fully understand why you need all that extra logic to determine if the playlist is a mix, when that last check seems robust enough? (as far as I know, mixes have always began with RD
).
This PR fixes issue #5454: Mix playlists rendering as "-1 videos" instead of showing a "Mix" label.
Summary of changes:
icon.sources
.playlist_id
starts withRD
.video_count
extraction by reading digits from badge text (locale/case agnostic) and fallback to-1
if not present.is_mix
flag on SearchPlaylist.is_mix
whenplaylistId
starts withRD
(fallback for non-lockup structures).is_mix : Bool = false
(@[DB::Field(ignore: true)]
to avoid DB impact).label_mix
key used by the UI overlay.Why:
video_count
parsing is English-only, causing UI to show "-1 videos" instead of "Mix" in many locales/variants.Validation:
UI behavior:
is_mix
reliably set, the view overlay displayslabel_mix
instead of numeric count for Mix playlists.Notes:
Fixes: #5454