goncalvesj.github.io

Turning a YouTube DJ set into a Spotify playlist with Azure AI Foundry

You know the feeling. You stumble onto a two-hour YouTube DJ set that absolutely slaps. You want it on Spotify. Forty-five minutes later you are squinting at a timestamped description, alt-tabbing between tabs, second-guessing every “feat.” spelling, and questioning your life choices. By track 12 you have given up.

I have lost that fight one too many times, so I built a small app to let the computer do the squinting. Paste a YouTube URL, get a Spotify playlist.

The source code is here:

https://github.com/goncalvesj/playlist-creator

The app itself runs on Azure Static Web Apps, but it is currently locked to my Spotify developer app’s allowlist for personal use, so there is no public link to share.

How it works

The flow is three steps from the user’s point of view:

  1. Sign in with Spotify.
  2. Paste a YouTube URL.
  3. Review the matched tracks, then create the playlist in your account.

Under the hood there are two clear halves:

Azure Static Web App
 |-- /                          Vite + React SPA (Spotify PKCE, search, playlist creation)
 `-- /api/extract-tracklist     Azure Function (Node 20)
     |-- YouTube Data API v3    Reads the video description
     `-- Azure AI Foundry       Structured-output tracklist extraction

The tracklist extraction

The interesting bit is asking the model for structured JSON, not free text. The function does roughly this:

  1. Apply a per-client rate limit and a short-lived per-video cache.
  2. Validate the body with Zod and resolve the YouTube video ID from any of the supported URL forms.
  3. Fetch the video snippet from the YouTube Data API and confirm the description actually looks like a tracklist (timestamps or - separators across at least a few lines).
  4. Call Azure AI Foundry’s v1 Responses API with a strict JSON schema, temperature: 0, and a prompt that explicitly tells the model to only return tracks that appear in the description.

The response comes back already shaped, so the function just validates and returns it:

{
  "videoId": "abc123",
  "videoTitle": "Boiler Room: Artist Name | Live Set",
  "channelTitle": "Boiler Room",
  "source": "description",
  "confidence": "high",
  "tracks": [
    { "artist": "Daft Punk", "title": "Around the World (Alex Gopher Remix)", "timestamp": "00:12:34" }
  ]
}

Spotify matching in the browser

Once the SPA has the tracklist, it calls Spotify’s search API for each track and picks the best match. A couple of small things that made a big difference:

Auth uses Spotify’s PKCE flow, so there is no client secret in the browser and no backend session to maintain.

The tech stack

A few things I would call out

Limitations

Honest about what it does not do:

If you want to see how the pieces fit together, or fork it for your own use, the repo is here:

https://github.com/goncalvesj/playlist-creator


Joao Goncalves

Joao Goncalves