Inspiration

All of us are avid music listeners so we knew we wanted to do something using the Spotify API to be able to pull the data from out playlists and library. We took inspiration from a service called ''Obscurify'' which uses the same API to give you data about your music tastes. Once we had all the data, we figured that we could turn it into a trivia game.

What it does

First we ask the user to input a link to a public Spotify playlist. Then, a python script runs that interface with the API and pulls the data from the corresponding playlist. For now, that data just includes a list of the album, artist, and song names. Then we have another python file that takes that data and procedurally generates simple trivia questions as string objects. Then we use Flask which is a python micro framework for developing web applications/servers. We output the data from the web-scraper to flask which renders a corresponding html file so that the user can play the game in their browser. We have a points system and leaderboard feature implemented so that users can compete against their friends.

How we built it

Our data scraper is built in python using the Spotify API GET requests. The GET request returns a json file containing information on the requested files. We have a separate file for processing the data returned from the web scraper into a format that can be used by the trivia game. The trivia game is also its own separate python file. If you wanted to you could play the whole game on the command line by changing the output of the game but instead we wanted the user to have a GUI in their browser. The Flask framework takes care of setting up a local web server and outputting the trivia game data formatted as html and css files.

Challenges we ran into

None of us had ever used an API so it took us a long time just to get authorization from Spotify to access playlist. In its current state, our web app can only access public playlists without requiring users to sign in. Once we had that playlist data, processing it was also a challenge. Each playlist has over a 1000 lines of metadata and trying to find the specific info we needed required some parsing. After finding the data fields that we needed, it also took some work to format it into a way that our trivia script could parse so that it could generate the questions. After we had all the individual components working, getting Flask to connect the data scraper, the trivia game, the html and running all on a local host took up the majority of our time. We originally wanted to host everything on a remote server such as Amazon AWS or Microsoft Azure but we ran out of time.

Accomplishments that we're proud of

We're really proud that we went from not knowing at all how to make requests to an API to being able to pull and parse data from Spotify playlists. When we managed to clear that roadblock and were able to display that raw data on the console, we were ecstatic. One of our team members had some vague experience with Python but this was his first real project working in Python.

What we learned

Aside from the implementation of Spotify APIs and more advanced python scripts, we learned how to use Dreamweaver to create more user friendly, aesthetically pleasing user interfaces to play the game. It makes On the Spot look spot on!

What's next for onTheSpot: A Spotify Trivia Game

Right now, the web app just runs on a local host so a big thing that we want to do is deploy it onto some sort of server so that you can just access it at a domain name. The Spotify API also has functions for securely logging into your account so that you can access private playlists as well as more user data such as who you are following and your listening trends. Our app currently only works with public playlists but we plan on implementing login functionality so that we can ask more in-depth questions. Our trivia app also only asks a fixed number of questions right now. We want to implement a feature that allows the user to dynamically pick how many questions are being asked as well as add a more complex points system that has different difficulties.

Built With

Share this project:

Updates