Minimal script to import a Spotify playlist (CSV export) into YouTube Music.
Built for personal use to move large playlists without paid services.
Note
This worked perfectly in my case to import 1300+ songs from Spotify into YouTube Music. Different setups or accounts may behave slightly differently, but the overall flow should still work.
Some online services do this too, but many are limited to ~500 tracks unless you pay.
How it works (short): The script reads the Spotify CSV, searches each track on YouTube Music using title, artist, album and ISRC, selects the best match using a simple score, adds it to the playlist and saves progress locally. This allows safe resume if the process stops.
In my case, around 40 tracks didn't match out of ~1370. That's still a solid result. Matching can be improved by adjusting regex or metadata handling.
Auth tokens may expire or change during large imports. If that happens, regenerating
browser.jsonis usually enough.Any improvements or contributions are welcome. Hope this helps.
- Python 3
- YouTube Music account
- Spotify playlist exported as CSV
(
Song,Artist,Album,ISRC)
python -m venv env
source env/bin/activate
pip install -r requirements.txtGenerate browser.json using your YouTube Music session:
ytmusicapi browser-
Open https://music.youtube.com and log in
-
Open Developer Tools (
Ctrl + Shift + I) -
Go to Network
-
In the filter box, search for
get?prettyPrint -
Select a request with:
- Status:
200 - Method:
POST - Domain:
music.youtube.com
- Status:
-
Right click → Copy → Copy request headers
-
Paste them into the terminal
-
Press Ctrl + D
python import.py "My Playlist.csv"- Creates a playlist using the CSV filename
- Adds tracks progressively
- Progress is saved in
added.json
If it stops (auth expires, network error):
python import.py "My Playlist.csv"Already imported tracks are skipped automatically.
python import.py "My Playlist.csv" --dry-runTests matching without adding songs.
