Automated Spotify Playlist Organizer - Sort and Queue Tracks by Popularity
🎧 Automated Spotify Playlist Organizer — Sort and Queue Tracks by Popularity
🧠 Overview
This workflow acts as your AI-powered Spotify DJ assistant. It retrieves your playlists, cleans and organizes them, sorts tracks by popularity, and automatically queues them for playback — creating a ready-to-play, personalized listening session.
⸻
⚙️ Step-by-Step Breakdown
Manual Trigger
Node: When clicking ‘Execute workflow’ Starts the workflow manually when you click “Execute” in n8n.
⸻
Get User’s Playlists
Node: Get a user’s playlists • Uses your Spotify OAuth credentials. • Calls Spotify’s API to retrieve all playlists from your account (returnAll: true). • Output: an array of playlists (name, URI, number of tracks, etc.).
🟢 This is your raw data source.
⸻
Clean & Deduplicate
Node: Clean & Deduplicate (Code node) This JavaScript block: • Normalizes input (handles arrays and multiple items). • Extracts only useful fields: name, uri, total. • Filters out playlists missing data. • Removes duplicates by URI.
🧹 Result: a clean, uniform list of your playlists.
⸻
Get a Playlist’s Tracks
Node: Get a playlist’s tracks by URI or ID • Fetches all tracks from a specific playlist. • Returns detailed info: name, popularity, artists, album, added date, etc.
🎵 This retrieves the actual songs from your chosen playlist.
⸻
Playlist Reorganizer
Node: Playlist reorganizer (Code node) This JavaScript block: • Collects all tracks from the selected playlist. • Avoids duplicates with seenTrackIds. • Extracts key fields: id, name, popularity, artists, album, added_at, url, etc. • Sorts songs by ascending popularity (less popular first).
📊 Result: playlist reorganized by song popularity.
⸻
Loop Over Items
Node: Split in Batches • Iterates over each track one by one. • Sends each song sequentially to the next node (“Add a song to a queue”).
🔁 Allows each song to be processed individually.
⸻
Add a Song to a Queue
Node: Add a song to a queue • Uses each song’s Spotify ID to add it to your Spotify playback queue (spotify:track:{{ $json.id }}). • Connected to the “Loop Over Items” node to continue until all songs are queued.
🎶 Result: your Spotify queue fills automatically with the reorganized tracks.
⸻
✅ Final Result
When you execute this workflow: It fetches all your playlists. Cleans and filters them. Extracts tracks from one selected playlist. Sorts them by popularity. Adds them to your playback queue.
🎧 End result: a fully automated “AI DJ” that reorganizes your playlists and lines up your music session — from discovery to playback.
⸻
🪪 Prerequisites
Before using this workflow: • You must have a Spotify account. • You need to set up Spotify OAuth credentials in n8n (Client ID, Client Secret, Redirect URI). • Ensure you have Spotify Premium (API queueing only works on Premium accounts).
⸻
🛠️ Setup Instructions Import this workflow into your n8n instance. Go to the Spotify OAuth2 API credentials section and connect your account.
Related Templates
Automate Free IP Analysis: NixGuard AI Summaries & Wazuh Integration
Supercharge Your Security Operations for Free Stop wasting time manually investigating suspicious IP addresses. This wo...
AI Agent with Ollama for current weather and wiki
This workflow template demonstrates how to create an AI-powered agent that provides users with current weather informati...
Automate Daily YouTrack Task Summaries to Discord by Assignee
Daily YouTrack In-Progress Tasks Summary to Discord by Assignee Keep your team in sync with a daily summary of tasks cu...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments