parse_song_run: fix view counts misparsed as artist in CJK locales#958
Open
Rishi943 wants to merge 1 commit into
Open
parse_song_run: fix view counts misparsed as artist in CJK locales#958Rishi943 wants to merge 1 commit into
Rishi943 wants to merge 1 commit into
Conversation
…#952) The views regex required a space between number and magnitude, but e.g. Japanese renders view counts as 3406万回視聴 with no spaces, so the run fell through and was returned as a bogus unlinked artist. Check the more specific duration/year patterns first, then treat any remaining digit-leading run as views, and only split off the first token when a space is actually present.
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.
Fixes #952.
parse_song_run()classified a non-linked run as a view count only when it matched^\d([^ ])* [^ ]*$— i.e. it required an ASCII space between the number and the "views" word. CJK locales don't have one: withlanguage="ja", view counts arrive as e.g."3406万回視聴", so the run fell through to theelsebranch and was returned as a bogus unlinked artist alongside the real one.Fix, keeping the existing heuristics' spirit:
(\d+:)*\d+:\d+) and year (^\d{4}$) — unchanged.Digit-leading unlinked artist text was already matched by the old views regex in the common
"21 Savage"-shaped case, so this doesn't introduce a new misclassification class — linked artist runs (withnavigationEndpoint) are unaffected either way.Verified against the runs from the issue (
ヨルシカ+3406万回視聴+3:48):{'artists': [{'name': 'ヨルシカ', 'id': 'UC...'}], 'views': '3406万回視聴', 'duration': '3:48', 'duration_seconds': 228}Regression-checked:
"34M views"→34M, non-breaking-space variant,"1,234,567 views","2020"(year),"3:48"/"1:23:45"(duration), and the unlinked-artist fixture case"The Wolfpack & Reel Wolf"(still artist — doesn't start with a digit).Note: written with AI assistance (Claude Code); verification outputs above were produced by running
parse_song_runsdirectly on the issue's data.