A script that syncs your Spotify liked songs to a YouTube Music playlist.
- Python 3 (Tested on Python 3.12)
- Install the necessary Python libraries:
ytmusicapifor interacting with YouTube Music.spotipyfor interacting with the Spotify API.
-
Clone this repository:
git clone https://github.com/itisFarzin/YTMusicify.git cd YTMusicify -
Create a virtual environment (recommended):
-
If you don’t have
virtualenvinstalled, first install it:pip install virtualenv
-
Create a virtual environment:
virtualenv venv
-
Activate the virtual environment:
-
On Windows:
.\venv\Scripts\activate
-
On macOS/Linux:
source venv/bin/activate
-
-
-
Set up your environment variables:
-
Copy the example
.envfile to.env:cp .env.example .env
-
Open the
.envfile and set the following variables with your credentials:SLEEP_TIME=5 SPOTIFY_CLIENT_ID=your_spotify_client_id SPOTIFY_CLIENT_SECRET=your_spotify_client_secret SPOTIFY_REDIRECT_URI=http://localhost:8888/callback YOUTUBE_CLIENT_ID=your_oauth_client_secret # Or use the browser method and set this to empty YOUTUBE_CLIENT_SECRET=your_oauth_client_secret # Or use the browser method and set this to empty ONLY_THE_FIRST_ARTIST=no PROXY=socks5://127.0.0.1:8080 # Optional
-
-
Install dependencies:
pip install -r requirements.txt
-
Set up the APIs:
- Follow the setup guide for ytmusicapi to configure access to YouTube Music.
- Follow the setup guide for Spotipy to configure access to Spotify.
- You must set "http://localhost:8888/callback" as the redirect uri in your Spotify application.
Once the setup is complete, you can run the script to sync your Spotify liked songs to YouTube Music:
python main.pyThis will authenticate with both Spotify and YouTube Music APIs and sync your liked songs from Spotify to a YouTube Music playlist. (It will take a while so be pension)
If you're using a proxy, ensure the PROXY variable is set in your .env file.
This project is licensed under the MIT License - see the LICENSE file for details.