Share your repls and programming experiences

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

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:

And its nemesis:

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:

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

Forbidden/CSRF Token Trouble

For some reason,'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.


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 2,572 page views (as of 11:30AM PST, 7/20)

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

(As you can see, users consistently use Smartify, with the exception of last Saturday, when my site was really buggy)

samdevz (31)

Nice! I like the final design of the front page it looks good even on a super wide screen! (Although lastpass thinks it's a password! Lol!) :)

ShadowCypher (31)

@samdevz Glad you like it - I tried to make it simple in design so that anyone could use it. Not sure why lastpass thinks it's a password, so maybe I'll take a look at that :)

TheNethrRaven (86)

Hello! I am currently trying to make a version of this that has more licensed music, could I have permission from you?

ShadowCypher (31)

@TheNethrRaven if you're requesting permission to create a similar application, sure, but if it's about the licensed music, that is all sourced from Spotify on my end

TheNethrRaven (86)

the REPL wont even load... @ShadowCypher

ShadowCypher (31)

btw if you're having overlap issues (as in - a different album pops up while you're going through your queue) you should try the fixed version:

Only reason that it's not on the live site is that the submission deadline passed, so I technically can't revise it until the competition ends :(

katyadee (1288)

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

ShadowCypher (31)

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

TikiHed (4)

i clicked and got ... TypeError at /

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

ShadowCypher (31)

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