Skip to content

Fix YTM search returning zero results for some catalogs (locale fallback) - #2795

Open
rizalxplo-dotcom wants to merge 1 commit into
spotDL:masterfrom
rizalxplo-dotcom:fix/ytm-locale-fallback
Open

rizalxplo-dotcom wants to merge 1 commit into
spotDL:masterfrom
rizalxplo-dotcom:fix/ytm-locale-fallback

Conversation

@rizalxplo-dotcom

Copy link
Copy Markdown

Problem

YouTube Music search ranking is locale-dependent. With the hardcoded language="de" in YouTubeMusic._create_client, filter=songs returns zero results for some catalogs while another locale returns full results.

Reported case: Genyee - Peace album (11 tracks) -> only 1/11 downloaded, log full of YouTube Music returned no usable results for ... after 3 attempts + LookupError: No results found. The videos fallback exists but its candidates get rejected by the name-match gate (e.g. single-word title Warmth vs Genyee - Warmth (Official Music Video) scores 55 < 60), so the locale miss is fatal.

Verified live: de+songs = 0 results, en+songs = 20 results with a perfect 100.0 match (verified + album + duration) for every track.

Fix

  • Default locale de -> en
  • New SEARCH_LANGUAGES = ["en", "de"]: retries now cycle locales instead of retrying the same failing locale (attempts: en -> de -> en)
  • Final log line lists locales tried, so future misses are debuggable

Verified 11/11 downloads on the reported album after the fix. Existing tests/providers/audio/test_ytmusic.py VCR tests pass.

…ack)

YouTube Music search ranking is locale-dependent: with the hardcoded
language=de, filter=songs returns zero results for some catalogs
(reported case: Genyee - Peace album, only 1/11 tracks downloaded,
'YouTube Music returned no usable results after 3 attempts').

Default to en and cycle SEARCH_LANGUAGES across retries instead of
retrying the same locale. Verified 11/11 on the reported album.

@kesonglab kesonglab left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the locale-fallback logic carefully.

What looks right: Hardcoding YTMusic(language="de") and then retrying with a new client that is still "de" cannot fix locale-empty catalogs. Cycling SEARCH_LANGUAGES = ["en", "de"] on retry is the minimal correct change. Attempt→language mapping for SEARCH_ATTEMPTS=3 is en → de → en, and the final log's locales tried comprehension matches that. Defaulting the first client to "en" (was always "de") is also a reasonable flip given the PR description.

Things to double-check / tighten (non-blocking but useful):

  1. Default locale change is a behavior change. First attempt used to be "de" for everyone; now it is "en". Worth one line in the PR body / changelog so this is intentional, not accidental.
  2. Third attempt repeats "en". With only two locales and three attempts, attempt 2 is a duplicate of attempt 0. Either drop to SEARCH_ATTEMPTS = 2, or extend the list (e.g. add "ja" / user locale) so retries stay informative.
  3. No regression test. A unit test that mocks YTMusic.search to return [] under "de" and a hit under "en", then asserts _create_client is called with the cycled language, would lock this in. I could not live-reproduce a de-empty / en-full split from this environment (filter="songs" returned 0 usable rows for both locales today), so the regression test matters more than a manual smoke.
  4. Client churn: recreating YTMusic on every failed attempt is fine at SEARCH_ATTEMPTS=3, but if this list grows, consider constructing clients lazily / caching per language.

Direction LGTM — happy to approve once (1) and ideally (3) are acknowledged.

This branch has not been deployed

No deployments
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.

2 participants