Skip to content

parse_song_run: fix view counts misparsed as artist in CJK locales#958

Open
Rishi943 wants to merge 1 commit into
sigma67:mainfrom
Rishi943:fix/song-runs-views-cjk-952
Open

parse_song_run: fix view counts misparsed as artist in CJK locales#958
Rishi943 wants to merge 1 commit into
sigma67:mainfrom
Rishi943:fix/song-runs-views-cjk-952

Conversation

@Rishi943

Copy link
Copy Markdown

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: with language="ja", view counts arrive as e.g. "3406万回視聴", so the run fell through to the else branch and was returned as a bogus unlinked artist alongside the real one.

Fix, keeping the existing heuristics' spirit:

  • Check the fully-specific patterns first: duration ((\d+:)*\d+:\d+) and year (^\d{4}$) — unchanged.
  • Then treat any remaining digit-leading run as views. Only split off the first token when a space is actually present; for scriptio-continua locales the full text is kept as the views value (there's no safe way to split the magnitude from the "views" word, and dropping it would lose information).

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 (with navigationEndpoint) 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_runs directly on the issue's data.

…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YTMusic.search method returns "views" wrongly (?) identified as an "artist" -...

1 participant