This Python program allows you to convert your liked songs from Spotify to a playlist on YouTube Music.
Before running the program, you need to set up some prerequisites:
-
Obtain Browser Headers: You need to obtain your browser headers and save them to a file named
browser_headers.txt
. To do this, follow the instructions below:- Open your browser and go to music.youtube.com.
- Open the Developer Tools (usually by pressing F12 or right-clicking and selecting "Inspect").
- Go to the "Network" tab.
- Reload the page.
- Look for a request named "account_menu" in the list of network requests.
- Copy the request headers (excluding the "POST" request line) and paste them into a new file named
browser_headers.txt
.
-
Spotify API Keys: You need to obtain your Spotify API client ID and client secret. If you don't have them already, you can create an application on the Spotify Developer Dashboard and obtain your keys there.
-
Install Dependencies: Run
pip install -r requirements.txt
to install the required Python packages.
- The program first uses the Spotify API to fetch your liked songs and saves the results to a JSON file named
spotify_results.json
. - Then, it searches for each song on YouTube Music and adds it to a new playlist.
- Finally, it saves the songs that could not be found on YouTube Music to a file named
songs_not_found.txt
.
- Make sure you have set up the prerequisites as mentioned above.
- Run the
main.py
file using Python 3:python3 main.py
. - Follow the prompts to enter your Spotify API client ID and client secret if you haven't already set them up in a
.env
file. - The program will then proceed to fetch your liked songs from Spotify and add them to a playlist on YouTube Music.
- The program utilizes the
spotipy
library to interact with the Spotify API and theytmusicapi
library to interact with the YouTube Music API. - If any errors occur during the process, they will be displayed in the console, and any songs that could not be found on YouTube Music will be listed in the
songs_not_found.txt
file.