Match Spotify playlist tracks to YouTube videos
This n8n workflow tracks a Spotify playlist and finds the matching YouTube video for each track. It is for people building music archives or players who want a reliable YouTube copy of every song, chosen by length so live or extended versions are skipped.
What it does
On a schedule it checks the playlist snapshot, and when it changed it syncs tracks into Supabase, marking removed ones for deletion. For each track it searches the YouTube Data API v3 with title and artist, reads the top five results and picks the first within plus or minus 10 percent of the Spotify duration.
How to use it
Connect Spotify, Supabase and a YouTube Data API key, and set the Discord node for alerts.
More in Discord and the n8n workflow library.
Full text
Front matter
name: Spotify Workflow
description: Triggered on a schedule. Connects Aggregate, Compare Datasets, Condition, Discord, Loop, Remove Duplicates, Schedule, Spotify. # Match Spotify Tracks to YouTube Videos ## This part finds the best YouTube video for a Spotify track using the YouTube Data API v3. It searches with the track title and artist, retrieves the top 5 videos, and selects the first one with a duration within ±10% of the Spotify track length. The matched video is added to a YouTube playlist, and its ID is saved in the database. ## Operation: - ## Uses Spotify data (title + artist) for search. - ## Ensures duration accuracy (±10% tolerance).
category: Automation
kind: Workflow
software: Aggregate|Compare Datasets|Condition|Discord|Loop|Remove Duplicates|Schedule|Spotify|Stop And Error|Supabase|Wait|You TubeSpotify Workflow
Triggered on a schedule. Connects Aggregate, Compare Datasets, Condition, Discord, Loop, Remove Duplicates, Schedule, Spotify. # Match Spotify Tracks to YouTube Videos
This part finds the best YouTube video for a Spotify track using the YouTube Data API v3. It searches with the track title and artist, retrieves the top 5 videos, and selects the first one with a duration within ±10% of the Spotify track length. The matched video is added to a YouTube playlist, and its ID is saved in the database.
Operation:
- ## Uses Spotify data (title + artist) for search.
- ## Ensures duration accuracy (±10% tolerance).
Steps
- Get playlist snapshot (spotify)
- Get playlist snapshot1 (spotify)
- If different snapshot (if)
- Get all musics (supabase)
- Update to_delete to true (supabase)
- Add music (supabase)
- Compare Datasets (compareDatasets)
- Spotify (spotify)
- No Operation, do nothing (noOp)
- Get all musics not in youtube playlist (supabase)
- Every day at noon (scheduleTrigger)
- Every day at noon + 1mn (scheduleTrigger)
- Every hour (scheduleTrigger)
- Wait 1 hour (wait)
- variables (set)
- Search video (youTube)
- Get video duration (youTube)
- Loop Over Items (splitInBatches)
- If video duration ~= music duration (if)
- Add music to playlist (youTube)
- Add youtube id to row (supabase)
- Discord (discord)
- Discord1 (discord)
- Set youtube id to NOTFOUND if no matching (supabase)
- Aggregate (aggregate)
- If no result (if)
- data (set)
- variables2 (set)
- variables1 (set)
- Loop Over Items1 (splitInBatches)
- data1 (set)
- Get playlist items (youTube)
- Playlist items to be deleted (compareDatasets)
- Get all musics that should be in playlist (supabase)
- Remove Duplicates (removeDuplicates)
- Remove video from playlist (youTube)
- Check for deleted videos (compareDatasets)
- Set youtube_video_id to null (supabase)
- Get all musics to be deleted (supabase)
- Delete music (supabase)
Import
Download the JSON from the GitHub source and import it in n8n (Workflows, Import from file).
Source and license
Source: https://github.com/Zie619/n8n-workflows/blob/main/Wait/0715_Wait_Schedule_Create_Scheduled.md
Author: Zie619, n8n workflow collection. License: MIT.
Shown here with formatting for the web. Keep the author and license notice when you reuse it.
Related entries
There are more like this in the members library
The n8n workflow library holds 1,814 entries. Members can search all of them by meaning and read every one in full.