Have you ever been deep in a YouTube rabbit hole, vibing to a playlist either you or someone made, and thought: "I wish I could listen to this on Spotify while I pretend to be productive at work"?
Well, my friend. It's your lucky day.
We are going to build a Python script that watches a YouTube playlist and automatically mirrors it on Spotify. Every day. Without you lifting a finger. Like a personal music intern who works for free and never complains.
And before you close this tab because I said "Python script" — stay with me. This tutorial is for everyone. Coders, non-coders, the person who still thinks Wi-Fi is witchcraft. We are going step by step, and nobody gets left behind.
What Are We Actually Building?
Here's the vibe in plain English:
"Every day at midnight, a computer (well, GitHub's computer — more on that later) checks a YouTube playlist, finds all those songs on Spotify, and keeps our Spotify playlist perfectly synced."
That's it. That's the whole product. Your YouTube playlist becomes a live feed for your Spotify playlist. Songs added on YouTube? Added on Spotify. Songs removed? Gone from Spotify too. You just... listen.
Here's a peek at what the finished script does when it runs:
----------------------------------------------------------------------------
Search Query: Don’t Stop ’til You Get Enough Michael Jackson
1. Found: Don’t Stop ’Til You Get Enough by Michael Jackson
----------------------------------------------------------------------------
Search Query: I Was Made for Lovin’ You Kiss
2. Found: I Was Made for Lovin’ You by Kiss
----------------------------------------------------------------------------
Search Query: Some Random Deleted Video
3. Skipped (Deleted/Private): [Deleted video]
----------------------------------------------------------------------------
Search Query: Very Obscure Song Title
4. Song Not Found: Very Obscure Song Title
Summary:
Total YouTube songs: 100
Found on Spotify: 97
Not Found on Spotify: 3
Added to playlist: 12
Removed from playlist: 5
Clean. Automatic. No manual effort. Let's build it.
What Is an API? (The Non-Nerd Explanation)
Almost every app you use — Spotify, YouTube, WhatsApp, Instagram — has two faces.
There's the pretty face: the app you see on your phone with the nice buttons and animations. And then there's the back door, which developers use to talk to the app directly without clicking any buttons. That back door is called an API (Application Programming Interface).
Think of it like this. If Spotify were a restaurant:
- The app on your phone is the dining area — nice tablecloths, a menu with pictures.
- The API is the kitchen window where you shout your order directly to the chef, skip the waiter, and get your food in a bag.
For almost every popular website — spotify.com — there's a developer.spotify.com. That's the kitchen window. And that's exactly where we're going.
In this series, we'll be talking to two kitchens:
- 🎵 Spotify's kitchen:
developer.spotify.com - 📺 YouTube's kitchen (run by Google):
console.developers.google.com
The Series Map
Here's where we're going, so you know what to pack:
| Chapter | What We're Doing |
|---|---|
| Chapter 1 (you are here) | Understanding the plan, setting up accounts |
| Chapter 2 | Setting up Spotify — creating an app, getting our secret keys |
| Chapter 3 | Setting up YouTube — getting our API key, finding our playlist |
| Chapter 4 | Writing the simplified code — what each part does |
| Chapter 5 | Running it on your computer for the first time |
| Chapter 6 | Deploying to GitHub Actions — making it run daily, forever, for free |
By the end of this series, you'll have:
- A Spotify playlist that auto-updates from YouTube
- The code on GitHub (public, your first open-source project!)
- A GitHub Action running it every day on a schedule
- Bragging rights
What You'll Need (Before We Write a Single Line of Code)
Good news: Chapter 1 requires zero coding. You just need accounts. Here's the shopping list:
1. A Spotify Account
Go to spotify.com and sign up if you haven't. The free tier works fine for our purposes. You don't need Premium to use the API.
Pro tip: Create a fresh playlist on Spotify right now and call it whatever you want (I will be using this: 70's Music Hits Playlist - Best of 70s Music). This is going to be the playlist our script writes to. Don't put anything precious in it yet — we're going to be playing with it. Later on you should be able to grab any playlist of your choice from YouTube Playlists.
2. A Google Account
You probably already have one. The YouTube API lives inside Google's developer tools, and you'll log in with your regular Google account. If you use Gmail, you're already there.
3. A GitHub Account
GitHub is where we'll store our code and (in the final chapter) run it automatically for free every day. Sign up at github.com if you don't have one.
GitHub is basically Google Drive, but for code. Instead of documents, you store code files. Instead of sharing a link to a spreadsheet, you share a link to your project. It's very normal and not scary.
4. Python (We'll Install This Together)
Python is the programming language our script is written in. We'll install it together in Chapter 5. For now, just know it exists, and it's friendly. It reads almost like English, which is why we picked it.
That's your whole list. Four accounts (you probably have three already), and we're off to the races.
A Quick Note on "Secret Keys"
When you connect to Spotify's or YouTube's API, they give you what are called credentials — essentially a username and password for your app. These are private. You never share them publicly.
In our project, we'll store these in a file called .env (dotenv — just a text file with a funny name). It looks like this:
CLIENT_ID=abc123
CLIENT_SECRET=xyz789
API_KEY=my_youtube_key_here
Think of it as the password notebook that lives only on your computer (and later, securely on GitHub). We will never put this file on the internet. The code goes on GitHub. The secrets stay private.
This is an industry standard practice. Every real app does this. You're already coding like a professional and you haven't written a line yet. 😎
What's Next?
In Chapter 2, we head to developer.spotify.com, create our app, and walk away with the three magic keys we need: a CLIENT_ID, a CLIENT_SECRET, and a REFRESH_TOKEN.
Yes, there are three of them. No, it's not complicated. Yes, I'll show you exactly where to click.
🎵 Final Product
After following the steps in this tutorial, your playlist should look similar to the one below:
🎧 View the completed Spotify Playlist
See you there. 🎧
Got questions? Drop them in the comments. See something confusing? Tell me which part so I can fix it. This series only works if everyone can follow along.
Top comments (0)