yt: Detect Mix playlists robustly and avoid '-1 videos' overlay (Fixes #5454)#5477
Open
naoNao89 wants to merge 1 commit intoiv-org:masterfrom
Open
yt: Detect Mix playlists robustly and avoid '-1 videos' overlay (Fixes #5454)#5477naoNao89 wants to merge 1 commit intoiv-org:masterfrom
naoNao89 wants to merge 1 commit intoiv-org:masterfrom
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
Member
|
I'm wondering: Did you use an AI tool to write this ? |
Author
|
@SamantazFox I use Copilot to create PR. |
|
@naoNao89 whats a "Compitol" ? |
Member
|
It's copilot with a typo |
SamantazFox
reviewed
Sep 20, 2025
Member
SamantazFox
left a comment
There was a problem hiding this comment.
I don't see where the frontend (HTML) code is using the new is_mix property. Did you forget to push a commit?
Comment on lines
-125
to
-126
| "preferences_default_playlist": "Default playlist: ", | ||
| "preferences_default_playlist_none": "No default playlist set", |
Member
There was a problem hiding this comment.
Please don't make unrelated changes.
Comment on lines
-659
to
-672
| # 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. |
Member
There was a problem hiding this comment.
Please consider adapting the comment instead of entirely removing it
Comment on lines
+668
to
+678
| # 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" |
Member
There was a problem hiding this comment.
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #5454: Mix playlists rendering as "-1 videos" instead of showing a "Mix" label.
Summary of changes:
icon.sources.playlist_idstarts withRD.video_countextraction by reading digits from badge text (locale/case agnostic) and fallback to-1if not present.is_mixflag on SearchPlaylist.is_mixwhenplaylistIdstarts withRD(fallback for non-lockup structures).is_mix : Bool = false(@[DB::Field(ignore: true)]to avoid DB impact).label_mixkey used by the UI overlay.Why:
video_countparsing is English-only, causing UI to show "-1 videos" instead of "Mix" in many locales/variants.Validation:
UI behavior:
is_mixreliably set, the view overlay displayslabel_mixinstead of numeric count for Mix playlists.Notes:
Fixes: #5454