This Python script retrieves the songs that you have liked on YouTube and adds them to a Spotify playlist. The script uses the YouTube Data API to retrieve the user's liked videos and identifies the songs in those videos. It then uses the Spotify Web API to search for the songs and add them to a playlist.
To use this script, you will need to set up a project in the Google Cloud Console and obtain API credentials for the YouTube Data API. You will also need to create a Spotify app and obtain API credentials for the Spotify Web API. You can then add the API credentials to the client_secrets.json file.
- Go to the Google Cloud Console.
- Create a new project or select an existing project.
- Enable the YouTube Data API for your project.
- Create credentials for a new OAuth 2.0 client ID.
- Select "Desktop app" as the application type.
- Download the client secret JSON file and save it as
client_secret.jsonin the same directory asyt.py. - Open the
client_secret.jsonfile in a text editor and add the following lines to the file, replacingyour_youtube_client_idandyour_youtube_client_secretwith your actual YouTube client ID and client secret:
"youtube_client_id": "your_youtube_client_id",
"youtube_client_secret": "your_youtube_client_secret"To run the script, simply execute the main.py file:
python main.pyThe script will prompt you to authorize access to your YouTube account and will then retrieve your liked songs and add them to a Spotify playlist.
This script requires the following Python packages:
- google-auth
- google-auth-oauthlib
- google-auth-httplib2
- google-api-python-client
- spotipy
You can install these packages using pip:
pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client spotipyOr you can download all of the dependencies by running the following command in the same directory as yt.py:
pip install -r requirements.txtThis project is licensed under the MIT License - see the LICENSE file for details.