feat: add move_tracks script for playlist track migration#45
Draft
jmlrt wants to merge 3 commits into
Draft
Conversation
- Implement hacks/move_tracks.py with URL/ID/name resolution - Sort tracks by artist name then album name (case-insensitive) - Support dry-run mode to preview changes without modifying Spotify - Pre-flight and post-operation playlist updates ensure DB stays in sync - Add 18 comprehensive unit tests (100% coverage) - Code follows ruff style and codebase conventions Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- When using --dry-run without -v/--verbose, output is minimal (just track list) - Verbose mode shows detailed logging of each operation - Better UX for quick previews vs. debugging
- Non-verbose mode now suppresses all INFO/DEBUG logging - Only warnings and errors are shown (cleaner output) - Verbose mode (-v) still shows full DEBUG logging
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
Add
hacks/move_tracks.pyscript to move tracks between Spotify playlists with flexible sorting. This is a one-off hack designed to be migrated into the CLI later.Changes
hacks/move_tracks.py (157 lines)
parse_playlist_identifier()— Extract 22-char ID from Spotify URLsresolve_identifier()— Resolve URLs/names to playlist IDs using existing utilitiesmove_tracks()— Core logic: sort by artist/album, add tracks, remove from sourcetests/test_move_tracks.py (475 lines)
Key Features
Testing
Example Usage
Future Migration
When ready to integrate into the CLI:
move_tracks()function tospotfm/spotify/misc.pyspotfm/cli.pyspotify command choices--source-playlist,--dest-playlist,--count,--dry-runhacks/move_tracks.pyThe function signature is already CLI-compatible.