Building a Spotify Playlist from Billboard Hits: A Python Script for Our Anniversary

For our wedding anniversary, I wanted to make something unique — a playlist of the top songs from when we first started dating and from our wedding day. That idea turned into a Python script that scrapes the Billboard Top 200 and builds a collaborative Spotify playlist automatically.
To bring the idea to life, I broke the project into two main parts: gathering the Billboard Hot 100 data for each anniversary date and then feeding that data into Spotify to create the playlist. For the first part, I used Python with requests
and BeautifulSoup
to scrape the Billboard charts, pulling both the song titles and artist names for the top 100 tracks. The Spotify side of things, however, wasn’t as smooth. I used the spotipy
library, but getting it to authenticate and do exactly what I needed was more difficult than expected—the online documentation was sparse, and figuring out the right parameters for searches, playlist creation, and track additions took a fair bit of trial and error. Even after that, I still had to handle quirks like mismatched search results between Billboard and Spotify.
One of the biggest quirks I ran into was that Billboard’s track listings and Spotify’s search results often didn’t line up perfectly. Sometimes it was a small difference—extra punctuation, a “feat.” instead of “featuring,” or a slightly different remix title. Other times, Spotify’s search wouldn’t return the correct song at all, even though I knew it was there. For this quick anniversary project, I took the simple approach: log any songs the script couldn’t find and add them manually. Out of roughly 400 songs, only 23 needed manual fixing, so it wasn’t a dealbreaker. Still, it’s an area ripe for improvement—next time I’d use a fuzzy matching algorithm to accept search results that are “close enough” to the Billboard entry instead of relying only on exact matches.
To make the matching process smarter, I’d turn to a fuzzy string matching library like rapidfuzz
. The idea is simple: instead of rejecting a search result outright when it’s not an exact match, compare the Billboard song title to the Spotify search result and calculate a similarity score. If the score is above a certain threshold—say 85%—it’s close enough to accept. This approach would have caught most of the 23 songs that slipped through. For example:
from rapidfuzz import process, fuzz
def find_best_match(billboard_title, spotify_results):
# spotify_results is a list of track names from the search
match, score, _ = process.extractOne(
billboard_title,
spotify_results,
scorer=fuzz.token_sort_ratio
)
return match if score >= 85 else None
With a bit of extra logic to handle artist names as well, this would make the playlist creation almost entirely hands-off—and spare me the manual cleanup step next time.
In the end, the playlist turned out to be exactly what I hoped for—a time capsule of songs that brought us back to those two special moments in our lives. Hitting play felt like flipping through an old photo album, but with music as the memories. While the code could be improved with fuzzy matching and better API handling, it delivered a unique anniversary gift that we’ll keep listening to for years. And like any good coding project, it left me with both a finished product to enjoy and a list of ideas for the next version.
Subscribe to my newsletter
Read articles from kyle benderoth directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
