JAMES RAYBOULD
Private build

Spotify Automations

Your whole music library, editable in plain English.

PythonSpotify Web APIGitHub ActionsClaude Code

The idea

Spotify's app is built for listening, not for managing. There is no bulk edit, no way to say “build me a playlist like this”, and no way to fix anything across a whole library at once. The API can do all of it. Point Claude Code at it and the library becomes editable by description — which turns out to be a clear way to see what AI is actually useful for. The API is plumbing. The useful part is that you describe the outcome in your own words and something else works out the steps.

What that lets you do

  • Build a playlist out of taste, not a search. I like EDM, so: take the songs I have already liked and go find the remixes and dance versions of them. That is Let's Remix below, a hundred tracks deep. No search box could produce it — it needs to know what I already like, then go looking for a different version of each one.
  • Or set a standing brief and let it run. The remix playlist was built once. This one never stops: twice a week it searches every podcast published in the last three days for AI, automation and productivity, scores them on how well they match, and replaces the playlist with the best ten. Three others run the same way — top songs this month, all-time favourites, deep cuts from albums I already own. I never open any of them to maintain them; they are simply current whenever I press play.
  • Edit in bulk. Remove hundreds of tracks in one pass. Find every album you appear to have saved by accident. Strip duplicates that came in from different releases of the same record.
  • Keep lists in step. Liked Songs cannot be shared. Mirror it to a public playlist and reconcile the two whenever you like, in both directions.
  • Take back what the platform keeps. Spotify builds you a Wrapped playlist every December, then makes it unshareable — the ones since 2021 cannot be embedded on your own site, and my 2017 has disappeared from the account altogether. Ten years of your own listening, in a format you cannot move. Rebuilt as playlists you own, they work anywhere, which is how all ten years ended up on the Music page.
  • Ask questions of your own listening. Which songs survive across ten years rather than one. What is a phase. Which of your top tracks are actually the family's.

Connecting it up

No server and no deployed app. A Spotify developer app, a refresh token on disk, and a terminal.

  1. 1
    Create a developer app

    At developer.spotify.com/dashboard. Add any local redirect URI — it only has to catch the callback once.

    http://127.0.0.1:8888/callback
  2. 2
    Ask for the right scopes

    The one people miss: reading your library, changing playlists and uploading cover art are three separate permissions, and a token without one fails with a 403 that does not say which.

    playlist-read-private playlist-modify-public playlist-modify-private
    user-library-read user-library-modify user-top-read ugc-image-upload
  3. 3
    Authorise once

    A short script opens the consent page, catches the redirect, and saves the tokens. After this it renews itself and you never sign in again.

    python3 reauth.py
  4. 4
    Then just ask

    From here it is a conversation. Claude reads the token, calls the API, and you describe the outcome rather than the endpoint.

    “Find every album where I've saved more than half the tracks,
    then build me a page where I can tick the ones to keep.”