Submit your best music themed repls!

← Back to all posts
13
Smartify - A Spotify-Powered thematic album queue
ShadowCypher (13)

We all know how it feels to be listening to an energetic song and suddenly getting pumped up, only to find that the next song in our shuffled queue is sad and depressing. That not only ruins the mood of the album, but also the general consistency.

Luckily, Spotify provided me enough breadcrumbs along the way through their various APIs to be able to build the solution to this very problem - a thematically consistent album generated, deemed "Smartify."

Smartify takes factors like "danceability," "valence," "key," "energy," and "speechiness" (as described in the FAQ in the website below) - all major thematic defining factors of songs that we commonly know - and computes the standard deviation between the "scores" for each of these factors for every song in the playlist. Then, Smartify will find the song with the smallest "standard deviation" and add it to the queue. The previous song is then appended to a "played" list, thereby ensuring that the song does not get replayed and that Smartify doesn't fall into a loop - after all, it's supposed to be smart.

After that, it'll generate a Spotify playlist for you (after you sign in and give it permissions) that follows a thematically consistent ordering. You can then add/remove songs at your leisure. If you're only using Smartify to find similar songs within playlists/albums, you can also preview the songs through Spotify's inbuilt player (although the preview is only 30 seconds).

You can also view the lyrics for songs that are not instrumentals :)
Edit: Not true since my API website is really slow... will have to find another way

TL;DR: What's so special about Smartify?
Fact is, if you have a playlist, it's very likely you don't want recommendations outside that playlist (or far off of the theme). Because of this, things like YouTube autoplay seem rather deprecated. On the other hand, our playlists are often shuffled into jumbled and inconsistent queue's in terms of how they sound - Smartify offers a two-fold solution by ensuring that the content of your albums/playlists stays the same, but that the order is optimized to be the very best by grouping similar songs together.

So, without further ado, here it is:
https://smartify--shadowcypher.repl.co

And its nemesis:
https://evilify--shadowcypher.repl.co

You can now search for your favorite albums/playlists, so you do not need the IDs below

Here are some ID's to try, unless you want to test your own:

Drake's Scorpion: 37i9dQZF1DX1YF6nTEHymi

Post Malone's Beerbongs and Bentleys: 6trNtQUgC8cgbWcqoMYkOR

Elton John's Diamonds: 1uzIyRT1QxDx4fMIX0UiAE

Getting an Album ID

For any album sharing link, it will be in the format:

https://open.spotify.com/album/ID

Just paste the ID into the homepage's text box and it should work.

Forbidden/CSRF Token Trouble

For some reason, repl.it's embedded applications cannot implement CSRF form tokens, so you'll need to open the site in a new window.

Overlapping Albums

Yep, unfortunately this is the biggest issue right now. Since the views reference one class, overlapping users may experience overlapping album. As such, I recommend that you create a playlist to ensure that your "progress" will not be deleted if another user logs on.

Refactoring

Since up to this point I've just been adding new features, the code looks somewhat dirty and is often repetitive - I have to fix this once I get the general sense that Smartify satisfies all features anyone would ever want.

Please let me know if you have any suggestions. I literally created this a week ago, and I'm quite proud of it but there's a chance I'm overlooking something. If you want me to let the site play the full songs, don't worry, that's exactly what I did (but you may need Spotify Premium - something I'll fix soon enough).

We're currently at 1687 page views (as of 1:00PM PST, 7/19)

Future Plans

  • Add domain & Cloudflare
  • Share playlists?
  • Lyrics comparison --> Really slow right now
  • Entropy --> Will allow external albums as entropy increases and conform to the current album as entropy is close to 0
  • Use of advanced data structures (actually taking a course on this haha) -> use priority queues
  • General refactoring
Commentshotnewtop
1
katyadee (833)

Ahh, it's not working for me yet :(

1
ShadowCypher (13)

@katyadee Should work now: sorry for the trouble :(

1
Xiija (1)

i clicked and got ... TypeError at /

get_album_art() missing 1 required positional argument: 'album'

1
ShadowCypher (13)

@Xiija Just fixed it. The playlists link is a bit funky right now, but I'll get that fixed soon