Spotify: Batch Spotify spotifysync API calls#6485
Conversation
There was a problem hiding this comment.
Pull request overview
PR make Spotify spotifysync do fewer HTTP call. It batch track metadata and audio-features fetch, so big library not hit rate limit so fast.
Changes:
- Add batch fetch for
/v1/tracks(50 ids per request) and/v1/audio-features(100 ids per request). - Deduplicate repeated Spotify track IDs within one run of
_fetch_info. - Add tests for chunking, endpoint usage, dedupe, and 403-disable behavior; add changelog entry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
beetsplug/spotify.py |
Implement batch endpoints + ID chunking/dedupe and shared disable logic for audio features. |
test/plugins/test_spotify.py |
Add response mocks + assertions for batching/dedupe/403 behavior. |
docs/changelog.rst |
Add Unreleased changelog entry for Spotify batching change. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6485 +/- ##
==========================================
- Coverage 72.05% 72.02% -0.04%
==========================================
Files 159 159
Lines 20562 20622 +60
Branches 3260 3272 +12
==========================================
+ Hits 14816 14852 +36
- Misses 5055 5063 +8
- Partials 691 707 +16
🚀 New features to boost your workflow:
|
… spotify_batch
|
@arsaboo let me know once you've addressed all my comments (I see the edits to irrelevant docstrings are not yet fixed) and I will re-review! |
|
@snejus, all comments are addressed, and the docstrings have been reverted (unless I missed something). |
|
Apologies, I accidentally approved but I intended to select Request changes 😅 |
Sync with upstream beets/master and resolve changelog conflict, keeping only the Spotify batch entry in the Unreleased section. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@snejus most of the formatting changes are made by doctstrfmt for the build to pass; there are no meaningful changes there. I reverted everything else. |
|
The issue with your unrelated changes in the docstrings is that this obfuscates the original author of that docstring. I often git blame specific lines in the codebase to find the relevant context for that line or change. Please undo the adjustments that I reviewed above. |
|
@snejus cleaned up everything. Apologies for the back and forth. |
This changes the Spotify plugin to batch
spotifysynclookups instead of making per-track API calls. It now:The previous implementation made one metadata request and one audio-features request per track, which was inefficient for larger libraries and increased the chance of hitting rate limits. Batching reduces request volume substantially while keeping the stored fields and user-facing behavior the same.
docs/changelog.rstto the bottom of one of the lists near the top of the document.)