Skip to content

Script that reads a JSON export of your Spotify library and attempts to import it in to YouTube Music

License

Notifications You must be signed in to change notification settings

jonathanbell/spotify2ytmusic-migration-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotify to YouTube Music Migration Script

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.

⚠️ This is still a work in progress and contributions are welcome. It works on my machine and I imported my Spotify library to YouTube Music without too much headache. Have fun.

"I want you to develop free software (for me)"

Prerequisites

  • 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)

Installation

  1. Clone/download this repo and cd into its directory
  2. python3 -m venv venv (or python -m venv venv if python already points to version 3 on your system)
  3. source venv/bin/activate will activate the virtual environment (if you're into that kind of thing)
  4. pip install -r requirements.txt
  5. 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)
  6. If using pyenv, run python3.11 ./src/main.py --help. Otherwise run python3 ./src/main.py --help or python ./src/main.py --help (if you have python setup to run as Python version 3 on your system). This command will list all of the available options/functionality associated with the script.

Usage

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.

Playlists

--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

--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

--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

--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

Errors do be like that

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.

YouTube (might) get mad

🚨 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.

About

Script that reads a JSON export of your Spotify library and attempts to import it in to YouTube Music

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages