Skip to content

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
nathom:devfrom
berettavexee:fix/deezer-async-and-perf
Open

fix(deezer): wrap gw.get_track in asyncio.to_thread, cache user ID, add loved tracks support#987
berettavexee wants to merge 2 commits into
nathom:devfrom
berettavexee:fix/deezer-async-and-perf

Conversation

@berettavexee

@berettavexee berettavexee commented Jun 13, 2026

Copy link
Copy Markdown

Summary

  • Fix: gw.get_track() was called synchronously inside an async context, blocking the event loop during concurrent downloads. Wrapped in asyncio.to_thread() to match all other GW API calls in this file.
  • Perf: Cache the logged-in user ID as logged_in_user_id during login() so that get_user_favorites() does not make a redundant get_user_data() API round-trip on every call.
  • Feat: Add DeezerFavoriteURL to support liked-track profile URLs of the form https://www.deezer.com/fr/profile/USER_ID/loved. Routes through get_playlist() via a synthetic favorites:{user_id} ID and fetches tracks via the GW API (get_my_favorite_tracks for own profile, get_user_tracks for others).
  • Refactor: Replace the hardcoded 2000 favorites limit with a class constant max_favorites = 10_000.

Notes

  • deezer-py's get_user_tracks() silently drops the limit argument when the target is the logged-in user (it routes to get_my_favorite_tracks() with default limit=25). The fix detects own-profile requests using the cached logged_in_user_id and calls get_my_favorite_tracks() directly with the full limit.

Test plan

  • Download a track/album/playlist to verify get_downloadable() still works after the asyncio.to_thread fix
  • Run rip url https://www.deezer.com/fr/profile/USER_ID/loved with own profile → resolves all liked tracks
  • Run with another user's public profile → resolves their liked tracks

🤖 Generated with Claude Code

berettavexee and others added 2 commits June 14, 2026 00:30
…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>
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.

1 participant