Tag2Tune is a Python/Tkinter desktop app that turns a local music library into Spotify playlists. It scans folders, extracts track information from audio metadata or filenames, writes local playlist ledger files, and imports those ledgers into Spotify with progress tracking, logging, cache support, and duplicate cleanup tools.
The current interface uses a modern Spotify-inspired dark theme with dashboard cards, large action buttons, side-by-side workflow panels, a progress card, and a collapsible activity log.
- Modern Spotify-style desktop UI with dark cards, green primary actions, toolbar shortcuts, status dashboard, progress percentage, and developer-style activity log.
- Local library scanning for MP3, FLAC, WAV, M4A/ALAC, AAC, OGG, AIFF, WMA, and APE files.
- Format filtering so a scan can target all supported formats or one specific audio type.
- Metadata extraction through Mutagen, with filename parsing fallback for files without usable tags.
- Playlist ledger generation as
_playlist_<FolderName>.txtfiles inside each scanned music folder. - Spotify OAuth authentication through Spotipy with token caching in
.spotify_oauth_cache. - Spotify track search using
artist:<artist> track:<title>queries when possible, with fallback searches. - Spotify search cache in
spotify_cache.jsonto reduce repeated API lookups. - Import from either a whole playlist folder or a single playlist text file.
- New playlist creation with editable playlist name, description, and public/private setting.
- Import into an existing Spotify playlist selected from your account.
- Existing-name conflict handling: add to the existing playlist, create a renamed copy, or cancel.
- Duplicate URI filtering during import so the same matched track is uploaded only once per generated playlist.
- Dedicated duplicate-removal tool for existing Spotify playlists, with keep-first or keep-last choices.
- Unmatched track report written to
unmatched_tracks.txt. - Daily log files in the
logs/folder. - Cancellable scan and sync operations.
- Settings window for Spotify credentials, redirect URI, and default music directory.
- Clear Cache and Open Logs tools from the menu.
- Python 3.10 or newer
- A Spotify account
- A Spotify Developer app
- Python packages from
requirements.txt
Install dependencies:
pip install -r requirements.txtThe runtime dependencies used by the app are:
spotipymutagen
The remaining packages in requirements.txt are helper, testing, or quality tools.
- Open the Spotify Developer Dashboard: https://developer.spotify.com/dashboard
- Create an app.
- Add this redirect URI unless you intentionally use another one:
http://127.0.0.1:8888/callback
- Copy the Client ID and Client Secret.
- Open Tag2Tune.
- Go to
Tools -> Spotify Settings. - Enter:
- Spotify Client ID
- Spotify Client Secret
- Redirect URI
- Default Music Directory, optional
- Click
Save Settings.
The settings are stored in config.json.
From the project folder:
python Tag2Tune.pyOn first Spotify use, the app may ask you to authorize in your browser and paste the redirected URL back into the prompt. The OAuth token is cached in .spotify_oauth_cache.
Use this when you want Tag2Tune to scan your local music folders and create local playlist ledger files.
- In the
Music Librarycard, clickBrowse. - Select the main folder that contains your music.
- Choose a format filter:
All Audio FormatsMP3 (*.mp3)FLAC Lossless (*.flac)WAV Hi-Res (*.wav)M4A/ALAC (*.m4a)AAC (*.aac)OGG (*.ogg)AIFF (*.aiff)WMA (*.wma)APE (*.ape)
- Click
Generate. - Watch the progress card and activity log.
For every folder that contains matching audio files, Tag2Tune writes a file named like:
_playlist_FolderName.txt
Each line is a track query such as:
Artist - Title
If metadata is missing, Tag2Tune tries filename patterns such as:
Artist - Title
Artist_Title
Artist | Title
01 - Artist - Title
If a scan is running, click Cancel in the Music Library card to request cancellation.
Use this when you already have generated _playlist_*.txt files and want to create or update Spotify playlists.
- In the
Spotify Importcard, choose the import mode:Playlist FolderSingle Playlist File
- Click
Browse. - Select either:
- A folder containing generated
_playlist_*.txtfiles, or - One generated playlist text file.
- A folder containing generated
- Leave
Update Existingenabled if you want existing playlist update behavior available during import. - Click
Import. - Follow the prompts.
During import, Tag2Tune searches Spotify for each ledger line, caches successful matches, removes duplicate matched URIs inside the upload list, and uploads tracks in batches.
If syncing is running, click Cancel in the Spotify Import card to request cancellation.
When importing a playlist file, Tag2Tune can ask how you want to handle the destination.
You can import into:
- A new Spotify playlist
- An existing Spotify playlist
For a new playlist, you can set:
- Playlist name
- Description
- Public or private visibility
If you choose an existing playlist, Tag2Tune loads your Spotify playlists and shows a searchable selector.
If you create a playlist with a name that already exists, Tag2Tune lets you choose:
- Add tracks to the existing playlist
- Create a renamed copy
- Cancel the import
Use this when you want to clean repeated tracks from a Spotify playlist.
- Make sure Spotify credentials are configured.
- Go to
Tools -> Remove Duplicates from Playlist. - Select a Spotify playlist.
- If duplicates are found, choose one option:
- Keep the first occurrence
- Keep the last occurrence
- Confirm the removal.
The tool compares duplicate Spotify track URIs and removes specific duplicate occurrences from the playlist.
The top toolbar provides quick access to the most common actions:
Generate Playlist: starts local playlist ledger generation.Import into Spotify: starts Spotify import for the selected source.Open Logs: opens thelogs/folder.Settings: opens Spotify and default-directory settings.
The dashboard cards show:
- Spotify connection/configuration status
- Number of cached Spotify track lookups
- Selected library or latest scan summary
The progress card shows:
- Current task
- Progress bar
- Percentage
- Current count or detail text
The bottom status text reports whether the app is ready, scanning, syncing, or missing Spotify credentials.
The activity log is shown at the bottom of the app. It mirrors runtime messages and is useful for checking scan and sync details.
- Click
Hide Activity Logto collapse it. - Click
Show Activity Logto restore it. - Use
Open LogsorTools -> Open Log Folderto open daily log files stored inlogs/.
Tag2Tune stores successful Spotify track searches in:
spotify_cache.json
This makes repeated imports faster and reduces duplicate API lookups.
To clear cached track lookups:
- Open the
Toolsmenu. - Click
Clear Cache.
The cache is safe to rebuild. Clearing it does not delete playlists or configuration.
Tag2Tune creates and uses these local files:
config.json: Spotify credentials, redirect URI, and default music directory.spotify_cache.json: cached Spotify track search results..spotify_oauth_cache: cached Spotify OAuth token.logs/YYYY-MM-DD.log: daily app logs.unmatched_tracks.txt: report of tracks that could not be matched on Spotify._playlist_<FolderName>.txt: generated playlist ledger files inside scanned music folders.
| UI option | Extensions |
|---|---|
| All Audio Formats | .mp3, .flac, .wav, .m4a, .aac, .ogg, .wma, .aiff, .ape |
| MP3 | .mp3 |
| FLAC Lossless | .flac |
| WAV Hi-Res | .wav |
| M4A/ALAC | .m4a |
| AAC | .aac |
| OGG | .ogg |
| AIFF | .aiff |
| WMA | .wma |
| APE | .ape |
Open Tools -> Spotify Settings and confirm that Client ID, Client Secret, and Redirect URI are filled in.
Use Generate first, or select the folder that contains files named _playlist_*.txt.
Check:
unmatched_tracks.txt- The daily log in
logs/ - The spelling and metadata of the source files
Spotify matching is only as good as the available metadata or filename text.
Confirm that the redirect URI in Spotify Developer Dashboard exactly matches the redirect URI in Tag2Tune settings.
Sync is disabled until Spotify credentials are configured.
The main application file is:
Tag2Tune.py
The app uses:
- Tkinter and ttk for the desktop interface
- Mutagen for metadata extraction
- Spotipy for Spotify API access
- Background threads and UI queues for long-running scan/sync operations
The UI is organized into helper methods such as:
_configure_styles_build_header_build_dashboard_build_toolbar_build_music_card_build_import_card_build_progress_card_build_console_build_statusbar
This project is licensed under the MIT License.