Skip to content

Noahffiliation/smart-playlists

Repository files navigation

Smart Playlists

Table of Contents

About

As a heavy Spotify user, I wanted to replicate iTunes' Smart Playlists feature in Spotify, specifically Recently Added, Top 25 Most Played, and Top 25 Least Played since I add music to my Spotify library/playlists all the time. Because my playlists are rather large at this point (1,000+ tracks), recent tracks don't get played very often and get lost in the sauce. This script running periodically keeps an automatically updated playlist of recently added tracks to my library in the last month as well as my top 25 most and least played tracks based on my last.fm scrobbles, since Spotify holds user plays in a vault until December of each year.

I also added a script to get new releases from artists I follow to a playlist, since Spotify's What's New feed sometimes delays showing new releases by a few days to a week.

There's also a script to find tracks that are in my Spotify library but not scrobbled at all on last.fm and add them to a playlist. The Top 25 playlists only work if everything in my library has scrobbles. I started scrobbling on last.fm in February of 2021, and my Spotify library was also quite large at that time, so there were plenty of tracks that I hadn't scrobbled yet. This script is probaly just a one-off, but will keep around in case scrobbles get missed for whatever reason.

Note

This was more-or-less completely vibe-coded with DeepSeek when it first became publically available and later edited and expanded with Claude. I wanted to try out the newest AI chatbot and also try out actual vibe coding and see how it goes for an inconsequential project. Generally, I'm pleasantly surprised with how well this turned out, functions just as intended.

Getting Started

Prerequisites

  • Spotify Developer account
  • An app created in the Spotify Developer Dashboard
    • Enable Web API in the settings
    • You shouldn't have any quota issues as long as you aren't running these scripts several times a day
  • last.fm API account

Installing

  1. Create a Python Virtual Environment

    python -m venv venv
    source venv/bin/activate
    
  2. Install Python packages:

    pip install -r requirements.txt
    
  3. Create .env

    touch .env
    
  4. Add info for CLIENT_ID and CLIENT_SECRET from the Spotify Developer App Settings A good default for REDIRECT_URI is http://127.0.0.1:8888/callback, make sure it matches in the Spotify Developer App settings SOURCE_PLAYLIST_ID is from your public Spotify playlist share link TARGET_PLAYLIST_NAME is the name of your new playlist LASTFM_API_KEY is from last.fm to get track scrobbles LASTFM_USERNAME is your last.fm username TOP_25_PLAYLIST_NAME is the name of your top 25 playlist BOTTOM_25_PLAYLIST_NAME is the name of your bottom 25 playlist

Usage

Once you fill out your .env, you can run either Python file to test it out

Use either a cronjob or Windows Task Scheduler to run the scripts periodically

Built Using

Authors

Acknowledgements

  • iTunes

About

Replicating iTunes' Smart Playlists in Spotify

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages