Habit building via Spotify API: Year of the Cat

Habit building via Spotify API: Year of the Cat


Habit building via Spotify API: Year of the Cat

Building habits is notoriously difficult. Studies show the average New Year's resolution only lasts 19 days. I can personally relate. In 2020, I decided to make my daily-song playlist which sound like very simple and easy habit. Though my dream fizzled after 22 days, and in 2021, it sputtered out at 113 days.

This year, 2023, I knew I had to try something different. I craved a simple yet consistent habit, something that required daily attention. While avoiding bad habits seemed easy, building good ones felt like a struggle.

Enter the 70th day. Discouragement loomed, and there was mainly two reasons for that:

  1. I am using my Spotify account almost everyday, but nothing was reminding me the habit. So I was forgetting adding songs. (Yes, I tried the habit trackers too, do not tell it :d)\
  2. Whenever I remember to add songs, after first 31 days, it was getting harder day by day to guess whether I added tracks that day or not :D

    💡 Luckily, a new idea sparked: ditch the forgettable reminders and leverage technology to keep me on track.

From Playlist to "Year of the Cat"

My "easy" habit needed a more engaging interface. In search of a more engaging experience, inspiration struck from multiple sources. Firstly, there was Rory, my recently adopted feline companion. Since it also happened to be the year of the Cat in the Chinese calendar, the theme practically wrote itself. And to top it all off, my love for Al Stewart's "Year of the Cat" album solidified the perfect playlist title: "Year of the Cat."

I procured a vinyl copy of the album and snapped some adorable photos of Rory.

polaroid picture collage for spotify playlist cover

Now came the development phase.

As an embedded software and robotics engineer, high-level programming wasn't my forte. But with relentless Googling, I solved all issues.

Building the Habit-Tracking Cover photo for Spotify Playlist

I tackled image editing using the Python Pillow library. Dealing with the Spotify API for the first time was a challenge, as it's not my usual area of expertise. However, by diligently reading the documentation (especially the tricky token refreshment section), I was able to navigate the process.

Using the API, I obtained tokens, fetched the current track count in the playlist, and initially displayed it directly on the cover photo. However, I soon realized the text was too small to be easily visible. This led me to create a more engaging indicator: a colorful progress bar. This bar not only served a functional purpose, but also provided a mini dopamine hit every time I added a song. When I missed a day, the bar turned red, serving as a gentle nudge to get back on track:

Conversely, adding a song transformed the bar to green, offering a satisfying visual reward.

Finally, I uploaded the updated image and set it as my playlist's cover photo.

The Final Question: Where to Run the Code?

Several cloud options were available, but for simplicity and affordability, Heroku emerged as the clear winner. It allowed me to run my code without the hassle of managing my own server infrastructure.
On Heroku, I configured a scheduler to update the playlist profile picture every 10 minutes.

A Year of Success (with Minor Missteps)

Fast forward to today! I've completed my "Year of the Cat" playlist with an impressive 90% success rate. There were occasional stumbles, of course, but the gamified progress bar kept me accountable.

This project is a testament to the power of a little creativity and technological intervention. It's also a reminder that even small, consistent efforts can yield significant results. While the final playlist boasts 365 songs, a few were added on incorrect days.

This year's victory motivates me to tackle new habits in the year ahead.

The Code and the Cat

All resources, including the code on Github, are completely public and free. Also, here is the playlist link and youtube shorts about it.


P.S. Cat is not included

rory the cat