No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-09-20 15:40:38 -05:00
.vscode Initial commit 2025-09-17 10:56:47 -05:00
src Proper runtime, docs, etc.. 2025-09-20 15:40:38 -05:00
.envrc.example Initial commit 2025-09-17 10:56:47 -05:00
.gitignore Initial commit 2025-09-17 10:56:47 -05:00
LICENSE.md Proper runtime, docs, etc.. 2025-09-20 15:40:38 -05:00
README.md Proper runtime, docs, etc.. 2025-09-20 15:40:38 -05:00
requirements.txt Proper runtime, docs, etc.. 2025-09-20 15:40:38 -05:00

YTMusic to Spotify Migrator

This is an Free and Fully Open-Source piece of software that allows you to collect a list of all Songs (Name, Artist(s) and Album) from your YouTube Music library. In addition, you can also add any list of songs -- though it's expected they'll come from this tool -- to your Spotify Saved Music playlist!

Running:

Run all python files as a module, i.e. python -m src.spotify or python -m src.ytmusic. This is because of relative import oddness, and is generally better practice. Both modules have a -h flag you can provide for help on the optional and required parameters. See the Environment Variables section below for info that you'll need to actually succeed:

Environment Variables:

Google Cloud SDK

Both GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are required as per the original YTMusic documentation found here

Spotify SDK

This project uses Spotipy, as such you'll need SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET and SPOTIPY_REDIRECT_URI to be defined in your environment.

To get these values, start by creating an App on the Spotify Developers Dashboard.

When asked for a Redirect URI, use http://127.0.0.1:9000 as the value. Set SPOTIPY_REDIRECT_URI to this same value.

The other two values will be provided to you in the dashboard.

YouTube Music

This is the entrypoint of this program, since it's assumed you're going from YTMusic -> Spotify, so you'll have to get the

Since there's a bug in the YTMusic API (as there is no public facing one...), the best route is to get the COOKIES and Authorization headers from your browser after going to https://music.youtube.com and browsing. Most requests to the /browse endpoint will have what you need, and they'll need to be set as environment variable through whatever means you prever. See the .envrc.example file for an idea of what things you'll need. The environment variables are:

YT_MUSIC_AUTH: This can be found in the Request Header, as mentioned. The key in the Request Header should be Authorization, and it will have a pattern somewhat like this: SAPISIDHASH 0123456789_0123456789ABCDEF000000000000000000000000_u SAPISID1PHASH 0123456789_0123456789ABCDEF000000000000000000000000_u SAPISID3PHASH 0123456789_0123456789ABCDEF000000000000000000000000_u

YT_MUSIC_COOKIE: This can also be found in the Request Header. The key in the Request Header should be Cookie, and it will have a pattern that starts out like this, but it's a very long string value: Cookie: VISITOR_INFO1_LIVE=xxxxxxxxxxx; VISITOR_PRIVACY_METADATA=xxxxxxxxxxxxxx%3D%3D; ...