Skip to content

Alcatraz312/Musical-time-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Musical time machine 🎵

GitHub last commit (by committer)

MIT License

GitHub top language

Create Spotify playlists of the top 100 Billboard songs from any year with ease! This Python program leverages web scraping to fetch the Billboard Hot 100 songs of a specified year and then uses a Spotify API (Spotipy) to create a playlist containing these chart-topping tracks.

Getting Started

Prerequisites

Before using this program, you'll need the following:

  • Python 3.6 or higher installed on your system.
  • A Spotify account to create playlists.
  • A Spotify Developer App to get API credentials.

Installation

  1. Clone this GitHub repository to your local machine:
git clone https://github.com/Alcatraz312/Musical-time-machine.git
  1. Change into the project directory:
cd Musical-time-machine
  1. Install the required python packages using pip:
pip install bs4
pip install Spotipy
pip install requests

Configuration

To use this program, you need to set up your Spotify API credentials:

  1. Create a Spotify Developer App: Go to the Spotify Developer Dashboard and create a new app. Note down the Client ID and Client Secret.

  2. Create a file named config.py in the project directory and add the following lines:

SPOTIPY_CLIENT_ID = 'your-client-id'
SPOTIPY_CLIENT_SECRET = 'your-client-secret'
SPOTIPY_REDIRECT_URI = 'http://example.com'

Replace 'your-client-id' and 'your-client-secret' with the credentials from your Spotify Developer App.

  1. Import client ID, client secret and redirect uri from config.py as following:
from config import SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, SPOTIPY_REDIRECT_URI
  1. Authenticate with spotify using from spotipy.oauth2 import SpotifyOAuth :
auth = SpotifyOAuth(client_id= SPOTIPY_CLIENT_ID,
                    client_secret= SPOTIPY_CLIENT_SECRET,
                    redirect_uri= "http://example.com",
                    scope= "playlist-modify-private",
                    show_dialog= True,
                    username= "Your spotify username")
  1. Run the code and if successful user should see a spotify web page show up automatically. Click on "Agree", it will redirect the user to the redirect uri given by the user, copy the entire url and paste it in the editor terminal to get the auth token.

  1. This will automatically add a file named "token.txt" in the directory. Store this value("token.txt") in the "cache path" parameter of the auth object defined above.

Usage

  1. Run the script by executing the following command:
python Musical-time-machine.py
  1. The program will prompt you to enter the date for which you want to fetch the Billboard Top 100 songs.

  2. The program will fetch the top 100 songs from the specified year on Billboard and create a new playlist in your Spotify account with those songs.

Contribution

  1. Fork the repository and create a new branch for your feature or bug fix.

  2. Make your changes, and ensure that your code follows the PEP 8 style guide.

  3. Write tests to cover your code if applicable.

  4. Create a pull request with a clear description of your changes and why they are needed.

  5. Your pull request will be reviewed, and once approved, it will be merged into the main branch.

license

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages