Repository navigation
Fix YTM search returning zero results for some catalogs (locale fallback) - #2795
Open
rizalxplo-dotcom wants to merge 1 commit into
Open
rizalxplo-dotcom wants to merge 1 commit into
rizalxplo-dotcom wants to merge 1 commit into
Conversation
…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
reviewed
Oct 2, 2026
kesonglab
left a comment
There was a problem hiding this comment.
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):
- 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. - Third attempt repeats
"en". With only two locales and three attempts, attempt 2 is a duplicate of attempt 0. Either drop toSEARCH_ATTEMPTS = 2, or extend the list (e.g. add"ja"/ user locale) so retries stay informative. - No regression test. A unit test that mocks
YTMusic.searchto return[]under"de"and a hit under"en", then asserts_create_clientis 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. - Client churn: recreating
YTMusicon every failed attempt is fine atSEARCH_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
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.
Problem
YouTube Music search ranking is locale-dependent. With the hardcoded
language="de"inYouTubeMusic._create_client,filter=songsreturns 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. Thevideosfallback exists but its candidates get rejected by the name-match gate (e.g. single-word titleWarmthvsGenyee - 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
de->enSEARCH_LANGUAGES = ["en", "de"]: retries now cycle locales instead of retrying the same failing locale (attempts: en -> de -> en)Verified 11/11 downloads on the reported album after the fix. Existing
tests/providers/audio/test_ytmusic.pyVCR tests pass.