So.. You want to give your money to one of the largest corporations in the world instead of the little 2006 Swedish company that could ("I think I can.. I think I can..") OK, well, here is a way for you to import your Spotify library into YouTube Music, you filthy animal.
Ugh.. I can't even believe I'm helping you do this. The only reason I made this script was to swap my subscription over to YT Music from Spotify "seamlessly". I feel like the pond scum of the Earth for doing so. I'm sorry, Daniel.
First of all, you need to export your Spotify library into a format that this script will understand. Probably, the easiest way for you to do that is to use this tool that I also wrote. The migration script in this repo is designed to be used with the JSON output produced by this Spotify Export tool.
Simply, download a binary that matches your system (Win/Mac/Linux) and run it. If you are on a Mac, you'll have to make the binary executable: chmod +x /path/to/spotify_export-mac64 && ./path/to/spotify_export-mac64
. After authenticating via Spotify a spotify_library.json
file will be placed onto your Desktop. Use this file with this Python script, provided here (in this repo).
This script depends heavily on the ytmusicapi
package. Since that package is written in fucking Python, so is this script.
- Python version 3.12.x (it's probably easiest to use a Python virtual environment - see below)
pip
git
(you probably already have this installed on Mac or Linux)
- Clone/download this repo and
cd
into its directory python3 -m venv venv
(orpython -m venv venv
ifpython
already points to version 3 on your system)source venv/bin/activate
will activate the virtual environment (if you're into that kind of thing)pip install -r requirements.txt
- The script has a major dependency on the
ytmusicapi
Python package. So before running any import commands, we need to authenticate with the YouTube Music API in order for it to work. Run:ytmusicapi oauth
(and follow the prompts in the CLI and browser) - If using
pyenv
, runpython3.11 ./src/main.py --help
. Otherwise runpython3 ./src/main.py --help
orpython ./src/main.py --help
(if you havepython
setup to run as Python version 3 on your system). This command will list all of the available options/functionality associated with the script.
Place your spotify_library.json
file in the data
directory (eg. data/spotify_library.json
) before running any of the commands.
If a song, artist, etc. cannot be found by the script while searching YT Music, the item will end up in the lost_and_found.txt
file here: data/lost_and_found.txt
. You can think of this file as a log of items that was not added to YT Music for whatever reason.
The output of --help
should be clear enough but I'll list a few examples here.
--spotify-playlists
List all of the available playlists to import (via the spotify_library.json
file)
./src/main.py --playlists
will import all of your Spotify playlists into YouTube Music.
For a more fine-grained/surgical approach, you can pass the names of which playlists to import via the --lists
property. Separate the names of the playlists with a comma.
Example: ./src/main.py --playlists --lists='lofi beats, Your Top Songs 2023'
--followed-artists
will import your existing flowed artists from Spotify into YT Music and "subscribe" you to each artist.
Example: python3.11 ./src/main.py --followed-artists
--liked-songs
will import all of your Spotify Liked Songs into YT Music's "Liked Music" list.
Example: python3.11 ./src/main.py --liked-songs
--saved-albums
creates new playlists with the artist and album name. Adds the tracks that are on the album to the playlist.
Example: python3.11 ./src/main.py --saved-albums
It would seem that unofficial, designed-for-browser YT Music API doesn't take kindly to overuse. I've encountered the error below more than once. Basically, just do what it says; wait a little while and try again.
Exception: Server returned HTTP 400: Bad Request.
You are creating too many playlists. Please wait a while before creating further playlists.
🚨 If you are worried about your YT account getting banned or flagged for scripting, using the --slow-motion
flag might be helpful. Basically, the script will operate in a much slower manner when slow motion is enabled in an attempt to not be flagged as "non-human activity" by YT Music.
This script/open source repository offers no warranty and will not be help liable for anything your stupid ass does. The code and functionality is offered as is. See the included LICENSE file.