This project is all about blending web scraping with the power of Spotify! Ever wondered what the top songs were on a specific day in history? With this tool, you can scrape the Billboard Hot 100 chart for any given date and instantly create a private Spotify playlist filled with those hits! 🚀
- 🗓️ Time Travel Through Music: Input any date in
YYYY-MM-DD
format, and the tool fetches the top 100 songs from the Billboard Hot 100 chart on that day. - 🖥️ Web Scraping Magic: Leverages the power of BeautifulSoup to extract song titles directly from the Billboard website.
- 🎶 Spotify Integration: Using the
spotipy
library, it creates a personal Spotify playlist and adds all the songs automatically! - 🛠️ Custom Playlist: The playlist is private by default, but you can easily tweak it to fit your needs.
- Choose a Date: The program prompts you to input a specific date (in
YYYY-MM-DD
format) for which you want to fetch the top 100 Billboard songs. - Scrape the Songs: The script uses BeautifulSoup to grab the song titles from the Billboard website for the specified date.
- Create Spotify Playlist: It authenticates with Spotify (using the Spotify Web API) and creates a private playlist.
- Add Songs to Playlist: The program searches for each track on Spotify and automatically adds them to your freshly created playlist! 🎧
- Python 3.x
- Spotify Account with developer credentials (Client ID and Client Secret).
- Spotify API Access via the spotipy library.
- Billboard Website Access for scraping the top Hot 100 songs.
-
Clone the Repository:
git clone https://github.com/ImanGholamii/Spotify_api_python_web_scraping_billboard.com.git
-
Install Dependencies:
In the project directory, run:pip install -r requirements.txt
-
Set Up Environment Variables:
Create a.env
file and include your Spotify credentials:CLIENT_ID='your_spotify_client_id' CLIENT_SECRET='your_spotify_client_secret'
-
Run the Script:
In your terminal, navigate to the project directory and run:python main.py
-
Input a Date:
When prompted, enter a date inYYYY-MM-DD
format (e.g.,2020-05-15
) to retrieve the Billboard Hot 100 for that day. -
Enjoy Your Playlist:
The script will create a playlist on your Spotify account titled "PyPlaylist," filled with all the songs from the Billboard Top 100 on that specific day!You can change the title simply.
billboard-to-spotify-playlist/
│
├── main.py # Main Python script for the project 📝
├── requirements.txt # Required Python packages 📦
├── README.md # Project documentation 📄
└── .env # Your secret environment variables 🔑
- The Billboard website uses pagination and has a lot of redundant HTML elements, but the BeautifulSoup library helps navigate through this to extract the song titles accurately.
- Spotify API might not find all the songs, depending on the availability of tracks, so some songs might not be added to the playlist.
- The playlist is private by default, but you can change this behavior by adjusting the Spotify API settings in the code.
Special thanks to the developers of Python, Spotipy, bs4 and Dr Angela Yu, and inspiration from password management best practices.
Feel free to fork this repository and submit pull requests to enhance the project. Contributions are always welcome! 🛠️
This project is licensed under the MIT License ⚖️.
If you like this project, please give it a ⭐️ on GitHub!
🎶 Time to relive the hits of the past! Create your own custom playlist based on the top 100 songs of any day in history with just a few clicks!