/Working-with-SpotifyAPI

Search for songs, create a playlist and add your favourite songs to your playlist in Spotify with this Python script.

Primary LanguagePythonApache License 2.0Apache-2.0

Spotify PlayList

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.

⚒️ Only Language / Tool

Python
Python

Demo

Screen.Recording.2022-10-31.at.21.50.48.mov

🧑 Follow these guide

  1. You will need to create a spotify account if you don't have one here Spotify
  2. Have python installed in your system if you don't have it already here Python Download

fork this repository

Fork this repository

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.

Clone the repository

clone this repository

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.

copy URL to clipboard

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 .

Setting up your Spotify

Let's set up your spotify so the script can work 💪

  1. Firstly
  • Visit Spotify and login into your account.

  • Visit Spotify for Developers navigate to the Dashboard Screenshot 2022-10-31 at 17 37 22

  • Like the image above, login with your spotify account.

  1. 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 👇 Screenshot 2022-10-31 at 17 46 30
  1. 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 the env_template and paste it in your created .env file then paste your CLIENT ID and CLIET SECRET respectively in the rightful place in your .env file. Screenshot 2022-10-31 at 17 50 15
  • Click on the Edit Settings
  1. Fourth
http://localhost:8080/callback/
  • Copy the link above and past it in the Redirect URIs exactly like the image below 👇 Screenshot 2022-10-31 at 17 53 12

  • 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

Example below: Screenshot 2022-10-31 at 17 26 17

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: Screenshot 2022-10-31 at 17 28 54

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: Screenshot 2022-10-31 at 21 42 29

License

Working-with-SpotifyAPI is licensed under the Apache License 2.0 - see the LICENSE file for details.

Contributors

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 💪

🙏🏽 Support

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