Skip to content

AndrewRoddy/Spotify_Popularity_Finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPOTIFY POPULARITY FINDER

Description:

Spotify Popularity Finder is the Final Project I created for the online course CS50P. This project allows the user to see the hidden Spotify statistic "Popularity".

This program allows the user to search for any artist on Spotify and access all of their albums and their popularity in table form. The user can then sort the album list by popularity. The user can then access every song within each album and sort by popularity.

The program shows album information and song information in table form sorted by popularity for ease of use. Allowing the user to see each song's popularity score allows the user to understand if others like certain songs as much as they do.

What is Popularity?

The Popularity statistic is important as it allows the user to see how popular a song is compared to the rest of the Spotify platform. The highest popularity score is 100 and the lowest is 0. Taylor Swift's song Cruel Summer is currently the 3rd most played song and has a popularity score of 99. According to Two Story Melody popularity score is based on total streams, how recently a song has been played, and the frequency that a track has been played. The more recent the streams of the song are, the more popular Spotify considers your track. This popularity stat also tells Spotify if they should recommend your song to others. This stat is a part of their song recommendation algorithm and can give insight into how popular a song currently is. Just because Uptown Funk by Mark Ronson and Bruno Mars has 1.8 billion streams does not mean that everyone is listening to it currently. In short, the popularity statistic tells Spotify how popular a song is and if it should be recommended to others.

Why I Made This

I am not a huge fan of singles, EPs, or LPs. I like albums. I enjoy being immersed in a sound structure built over the course of an hour. It is difficult to contain an artist's entire message within just 3-5 minutes but with an album an artist can take the listener on a journey through their experiences. In Ready To Die by The Notorious B.I.G., the album begins with him being born. The listener hears his mother struggling and baby B.I.G. crying after being born. The album ends with him dying. The listener hears the gunshot that kills him. This level of immersion cannot be achieved within a single or a few songs.

I created this entire project based on one question. Which Mac Miller album is more popular: Swimming or Circles? This question led me to weeks of work, destroying my idea of a "quick weekend project".

How I Made This
Step 1 - Getting The Data

To get the data necessary for this project I used the Spotipy module. This module makes accessing the Spotify API quick and easy within Python. My function setup_spotipy creates a global variable to easily call the Spotipy functions without having to use the client credentials and the client id over and over again. Using Spotipy functions like search(), artist_albums(), and album_tracks() I can easily obtain all of the data I need to create this program. The problem is the data is all organized within dictionaries upon dictionaries. Using the pprint module I learned in Lecture 6 I was able to better understand where in the dictionaries I needed to get my data from.

This allowed me to create my first function artists_albums(). Using this function I can easily input the artist_id as a parameter and output a list of the artist's albums, the release date, the track number, and the album id. There was only one problem: I could not find the album's popularity anywhere. This was a problem as the entire purpose of my program was to find the album's popularity. Luckily I found out the only way to acquire album popularity and it is not easy.

Step 2 - Actually Getting The Data

The first step in finding the popularity of an album is to find the popularity of one song in the album. First using the album id you can find the song id of each song. Then using the song id you must get the data to find the track id. Then using the track id you can find the track popularity. After this, you can add up all of the tracks and average the popularity scores to get the overall album popularity. Artist -> Album -> Song -> Track -> Popularity This process involved heavy use of dictionaries which taught me a lot more about dictionaries than I already knew.

Step 3 - Data Visualization

The best way to visualize song data is to create a table. We see this time and time again. | Song Name | Artist Name | Album Name | Release Date | Song Length |

I wanted to create something similar. I thought I could easily convert the list's data into a table using the Tabulate module. The problem is the song name lengths were all very random and the time was in milliseconds. The main problem was there was always one song like "Castles Crumbling (feat. Hayley Williams) (Taylor’s Version) (From The Vault)" that would widen the "Song Name" section of the table to half the size of the screen. Spotify's solution to this problem was if a song exceeded a certain amount of characters it would shorten it and add three dots to the end. So I decided to do the same thing in Python by creating a function called length_limit(). This function takes two parameters: the name of the song and the length you want to shorten the name to. Then I created the function ms_to_m() using the datetime module to convert the milliseconds the API gives me to "minutes : seconds".

Originally I had these features as a parameter in the artists_albums() function where if the third parameter was True it would return a table instead of data but I eventually found this confusing. I instead separated this feature into albums_table() and songs_table().

I also created the ascii_art() function which prints ASCII art for the project.

Step 4 - User Experience

Something very important in software is how easily it is for the user to interact with the software. If somebody has to be taught how to use a software the software is generally less useful. When creating the software I had two options:

  1. Have the user copy and paste the artist id into the terminal
  2. Allow the user to search for the artist's name Option 1 was much easier for me and option 2 was much easier for the user. I chose option 2 but still allowed the user to put the artist id into the terminal. To do this I created a function named artist_search(). This function checks all of the results from the search and then uses an algorithm to select for the same name input or a similar name input.

I also created the artist_select() and album_select() functions as a way to use the program in a much more user-friendly experience.

Conclusion

I am very happy with how this project turned out. I learned a lot about coding in python while creating this software. I was very happy to see my friends trying out the software and enjoying it. Making something that others can enjoy is very exciting, especially doing it with code.

By: Andrew Roddy

About

Allows the user to search through Spotify's entire data-set. Find any artist on Spotify and access every albums and album popularity in table form.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages