A project where you can create a playlist that you love and add songs to your playlist in a just a click.
With this python script you can time travel to your desired date or season that matters most to you.
For example if you want to know the top songs at a specific date or maybe a memory you want to bring back, all you need is to input the date
and you have all the favorite songs of that time in a playlist created for you by this script in your speotify account and you enjoy it.
Follow these steps to set up the python script with your spotify account.
Python |
Screen.Recording.2022-10-31.at.21.50.48.mov
- You will need to create a spotify account if you don't have one here Spotify
- Have python installed in your system if you don't have it already here Python Download
Fork this repository by clicking on the fork button on the top of this page. This will create a copy of this repository in your account.
Now clone the forked repository to your machine. Go to your GitHub account, open the forked repository, click on the code button and then click the copy to clipboard icon.
Open a terminal and run the following git command:
git clone "url you just copied"
where "url you just copied" (without the quotation marks) is the url to this repository (your fork of this project). See the previous steps to obtain the url.
For example:
git clone https://github.com/Kellsonphilips/Working-with-SpotifyAPI.git
where this-is-you
is your GitHub username. Here you're copying the contents of the Asakatsu-Website repository on GitHub to your computer.
Next* You can drag and drop the project directory to your favorite IDEs or code editor.
If you have VS Code set up then you can open the project from your terminal directly by running this command
cd Working-with-SpotifyAPI
code .
Let's set up your spotify so the script can work 💪
- Firstly
-
Visit Spotify and login into your account.
-
Visit Spotify for Developers navigate to the Dashboard
-
Like the image above, login with your spotify account.
- Secondly
- Click on Create An App to create an app for what you are building
- Give your App a name and the description
- Example below 👇
- Thirdly
- Copy the CLIENT ID and the CLIENT SECRET
- Using the
env_template
provided for you in this project - Create a
.env file
, copy all in theenv_template
and paste it in your created.env file
then paste yourCLIENT ID and CLIET SECRET
respectively in the rightful place in your.env file
. - Click on the Edit Settings
- Fourth
http://localhost:8080/callback/
-
Copy the link above and past it in the Redirect URIs exactly like the image below 👇
-
And Save We are done with the spotify developer App
To make your environmental variables recognized or read by the script. Inside your working directory We need to install all the modules needed for this script
- Cpy each of these commands and run it to install the modules
pip3 install python-dotenv
pip3 install bs4
pip3 install requests
pip3 install spotipy
We are all set to test our script!!!
After all the above the steps are completed.
Run the main.py
file
If everything is fine, you will be prompted to input the date you want to check the top 100 songs on that date.
Date format:
YYYY-MM-DD
If a song is not found in Spotify , the name of the song will be logged in the console like above. Check your Spotify and you will find your playlist created and top100 songs added in the playlist. Like below:
The songs are 99 because 1 song wasn't found in Spotify.
Also if you try same date without Renaming the previous playlist with same Date, you can't have multiple playlists with the same name and same songs. You will be notified in console like below:
Working-with-SpotifyAPI is licensed under the Apache License 2.0 - see the LICENSE file for details.
If you have anything to add to this script, you are welcome to do so because there are many features we can add to this simple code and make it even more great for everyone. Do make your contributions and send a PR to feature in the contibutore as below 💪
This project needs a star️ from you. Don't forget to leave a star✨ You can contact me through my social media accounts if you need any help. I would be very pleased to offer my help. Thank you