fix(deezer): wrap gw.get_track in asyncio.to_thread, cache user ID, add loved tracks support#987
Open
berettavexee wants to merge 2 commits into
Open
fix(deezer): wrap gw.get_track in asyncio.to_thread, cache user ID, add loved tracks support#987berettavexee wants to merge 2 commits into
berettavexee wants to merge 2 commits into
Conversation
…dd loved tracks support - Fix: gw.get_track() was a blocking synchronous call inside an async context; wrap it in asyncio.to_thread() to avoid stalling the event loop during concurrent downloads. - Perf: cache the logged-in user ID in login() (_logged_in_user_id) so get_user_favorites() does not make an extra get_user_data() API round-trip on every call. - Feat: add DeezerFavoriteURL to support profile liked-track URLs of the form https://www.deezer.com/fr/profile/USER_ID/loved. - Refactor: replace the hardcoded 2000 favorites limit with a class constant _MAX_FAVORITES = 10_000. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rename _MAX_FAVORITES -> max_favorites (matches max_quality style) and _logged_in_user_id -> logged_in_user_id (matches logged_in style). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5 tasks
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.
Summary
gw.get_track()was called synchronously inside an async context, blocking the event loop during concurrent downloads. Wrapped inasyncio.to_thread()to match all other GW API calls in this file.logged_in_user_idduringlogin()so thatget_user_favorites()does not make a redundantget_user_data()API round-trip on every call.DeezerFavoriteURLto support liked-track profile URLs of the formhttps://www.deezer.com/fr/profile/USER_ID/loved. Routes throughget_playlist()via a syntheticfavorites:{user_id}ID and fetches tracks via the GW API (get_my_favorite_tracksfor own profile,get_user_tracksfor others).2000favorites limit with a class constantmax_favorites = 10_000.Notes
deezer-py'sget_user_tracks()silently drops thelimitargument when the target is the logged-in user (it routes toget_my_favorite_tracks()with defaultlimit=25). The fix detects own-profile requests using the cachedlogged_in_user_idand callsget_my_favorite_tracks()directly with the full limit.Test plan
get_downloadable()still works after theasyncio.to_threadfixrip url https://www.deezer.com/fr/profile/USER_ID/lovedwith own profile → resolves all liked tracks🤖 Generated with Claude Code