The purpose of the script above is to remove any songs by a specific artist from a user's "Liked Songs" playlist. The program relies on Spotipy for the API calls and any interactions with the Spotify servers.
In order to run the project, you'll have to either fork the repository or copy the following files into your own project folder:
- requirements.txt
- remove_artist.py
Once the repository is forked and you've opened it on your IDE of choice (or you've simply copied the files into said repository), run the command below to install the libraries in the requirements.txt file.
pip install -r requirements.txt
It might get a bit complicated from here, but it'll be very simple. Go to the Spotify Developer website and create an account. Once you've created an account, go to your dashboard and click the "Create app" button.
Go to the process and creating it, and you can just keep the "App Status" on "Development mode" and set the Redirect URI's to "http://127.0.0.1:9090" for the APIs used, select the "Web API"
After that, go back to the project folder, and create an ".env" file and in that file create the following variables:
- SPOTIPY_CLIENT_ID='Your apps Client ID'
- SPOTIPY_CLIENT_SECRET='Your apps Client Secret'
- SPOTIPY_REDIRECT_URI='the Redirect URI we defined earlier'
After that, just simply go into the code and change the name of the artist from "Mon Rovîa" to whichever artist you'd like to remove from your playlist, and click the run button on the IDE or run the following command from the root directory of the project folder:
py remove_artist.py
The reason for the Dockerfile if you haven't guessed is because I'm currently running this script from a docker container, which is inside of a raspberry pi and scheduled to run at noon everyday with cron.
Awhile back I added myself to the artist's wishlist for a song he was set to release. When the song was released, it was added to my Liked Songs as expected and while it was a lovely song, it wasn'y my style.
The issue occurred later when the artist released an album and every song was added to my playlist. I was permenantly added to the artist wishlist, which meant for the next 4-5 months I had to manually remove each song of his that was added.
I tried changing the email attached to my account but that didn't work. I could have reached out to Spotify, but I didn't think they could do much, I also could have reached out to the artist over the issue, but I didn't think he'd see my message for awhile.
So I ended up developing a version 1 of this code (super slow, unoptimzied, and terrible coded) that worked and launched it on AWS.
It worked, I was happy...until the bills for the AWS services came in but it was a necessary evil...until I got tired of paying for AWS.
Finally, I took the code from version 1, cleaned it up, made it nice and pretty, and launced in a docker container inside of a raspberry pi.