One day I was organizing some directories on my pc and I found the old songs I used to listen. I wanted to add those songs to a playlist on spotify, but there were like 300 songs, it would take ages to do it manually, so I decided to have python do it for me.
It's quite simple: it saves the names of all the songs, without the extension, looks for their id's on spotify and adds the songs to the playlist you chose.
First of all, you need to have python installed in your pc, you can find the latest version here: https://www.python.org/downloads/
After that, you need to download this repository by clicking on code and download ZIP:
Or clone it by using:
git clone [email protected]:RuaN-debug/Auto_Spotify.git
Now you need 3 things: the complete path of the directory with the songs in your pc, the id of the playlist you want to add the songs and a token to authorize that. To get the playlist id you can go to spotify, copy the link of the playlist and the id will be the number after playlist/ and before the ?, like the example below:
https://open.spotify.com/playlist/0GfSUFhYrgdJfkIJO2kpbz?si=38b8654a512a4ddf
id = 0GfSUFhYrgdJfkIJO2kpbz
After getting the id you need the token to authorize python to do the work, you can get it by using the official api of spotify: https://developer.spotify.com/dashboard/login Now, after logging in, you go to: https://developer.spotify.com/console/post-playlist-tracks/?playlist_id=0GfSUFhYrgdJfkIJO2kpbz&position=&uris= and paste the playlist id:
Click on Get Token:
And mark the playlist-modify-public or playlist-modify-private, depending on the type of your playlist (public or private) and request the token.
It will appear on the box to the left of the button. all you need to do is copy it.
Finally, you have everything you need, now in order to make it work you need to access the main.py file and paste the token and the path of the directory with the songs:
Then go to spotify_client and paste the id of your playlist:
Now, all you have to do is to install the requirements with:
pip install -r requirements.txt
And run the main.py file, you can do that with:
python main.py
Remember that the token is not permanent, you have to get another token every few minutes.