- Notifications
You must be signed in to change notification settings - Fork11
nkhilgaba/YoutubeToSpotify
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Python script to fetch tracks of music channels on Youtube, find them on Spotify and add them to a playlist.The video titles from Youtube are filtered and then searched on Spotify for near perfect results. A CSV file keeps track of the tracks that are added to the Spotify playlist so the script can be executed when required.
You need these before running the script:
Login toSpotify Developer Dashboard and create a new app to obtain the Client ID and Client Secret.Add these toCLIENT_ID andCLIENT_SECRET in the code.After this, click edit settings of the newly created app and addhttp://localhost/ to Redirect URIs and save.
Get the Youtube API keyhere and add it toAPI_KEY in the code.
Spotipy : Spotipy is a lightweight Python library for the Spotify Web API.With Spotipy you get full access to all of the music data provided by the Spotify platform.
TheGoogle APIs Client Library for Python for making requests to Youtube
Create a new Spotify Playlist and name it anything you want.Get your spotify username and the playlist id.Copy the username and playlist ID and add them toSPOTIFY_USERNAME andYOUTUBE_PLAYLIST_ID in the code respectively.
Right click on the playlist in Spotify and go to Share > Copy Spotify URI.
You will receive a URI like this:
spotify:user:john:playlist:70WcLyhxyzRuSGf678MyPd
To install Spotipy
pip install spotipy
To install Google API
pip install google-api-python-client
To add channels from Youtube, simply access a channel page and examine the URL. If it is like:
https://www.youtube.com/user/ChillStepNation
Just add the part afterhttps://www.youtube.com/user/ toCHANNEL_USERNAMES list in the code. In this case, ChillStepNation.
If the URL is like:
https://www.youtube.com/channel/UCkjnVMHy
Add the part afterhttps://www.youtube.com/channel/ (Here, UCkjnVMHy) toCHANNEL_IDS dictonary in the code in the format:
{'channelName' : 'channelID'}
To change the number of search results for each channel changeMAX_RESULT in the code. Default is 20.