Repository navigation
Conversation
When the Deezer media endpoint rejects a track URL request with error code 2002 (WrongGeolocation), the restriction usually only applies to the lossless (FLAC) master; the MP3_320/MP3_128 formats of the same track are often still available in the user's country. Previously, get_downloadable only retried with the FALLBACK track id at the same quality and otherwise raised NonStreamableError, so tracks were skipped even though an MP3 version could be downloaded. Now, on WrongGeolocation the same track is retried at one quality lower (FLAC -> MP3_320 -> MP3_128) when lower_quality_if_not_available is enabled (the default). The FALLBACK track is only tried once even MP3_128 is geoblocked, and NonStreamableError is raised only when nothing is available. Fixes nathom#806 Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
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
When downloading from Deezer, the media endpoint (
media.deezer.com/v1/get_url) sometimes rejects the track URL request with error code2002, whichdeezer-pysurfaces asWrongGeolocation("can't be streamed in country X"). In practice this restriction usually only applies to the lossless (FLAC) master — theMP3_320/MP3_128formats of the same track are typically still available in the user's country.DeezerClient.get_downloadableonly retried with theFALLBACKtrack id at the same quality and otherwise raisedNonStreamableError, so tracks were skipped (see #806) even though an MP3 version could be downloaded.Fix
In
streamrip/client/deezer.py, ondeezer.WrongGeolocationthe same track is now retried at one quality lower (FLAC -> MP3_320 -> MP3_128) whenlower_quality_if_not_availableis enabled (default:true), before falling back to theFALLBACKtrack id.NonStreamableErroris raised only when evenMP3_128is geoblocked and no fallback track exists.The resulting
DeezerDownloadablegets the right extension (mp3for quality <= 1) and size automatically, since it derives them from the resolved quality.Tests
Added unit tests in
tests/test_deezer.pycovering:quality == 1,.mp3)quality == 0)NonStreamableErrorFALLBACKid present -> downloads the fallback track as MP3lower_quality_if_not_available = false-> no quality fallback, raises immediatelypytest tests/test_deezer.py: 9 passed, 1 skipped (integration test needsDEEZER_ARL). Full suite: only pre-existing unrelated failure intests/test_meta.py::test_album_metadata_qobuz(also fails onmain).