Neil Mahajan
Personal Project
September 2025

šŸŽµ Spotify to YouTube Music

A two-part tool that exports liked songs from Spotify using Go and automatically likes them on YouTube Music using Python, providing a free alternative to paid migration services.

Go 1.22+
Python 3.10+
Spotify API
YouTube Music API
JSON
OAuth 2.0
ytmusicapi
HTTP Clients
Migration Process
# Step 1: Export from Spotify
$ cd spotify && go run .
āœ… Exported 3,254 liked songs to JSON

# Step 2: Import to YouTube Music
$ cd ../youtube && python main.py
[1] Liked: DUMBO by Travis Scott
[2] Liked: LOCO by Yeat
[3] Liked: Sicko Mode by Travis Scott
...
āœ… Successfully migrated 3,182 songs
āš ļø 72 songs saved to unmatched.json

Project Overview

Spotify to YouTube Music is a free, open-source migration tool that I created during my personal transition from Spotify Premium to YouTube Music Premium. Frustrated by the limitations and costs of existing migration services, I built this two-part solution to automatically transfer all liked songs between platforms.

The tool consists of a Go program that fetches all liked songs from Spotify using the official API, and a Python script that uses the ytmusicapi library to search for and like matching songs on YouTube Music. This approach ensures reliability and transparency while providing full control over the migration process.

The project demonstrates practical API integration, cross-language programming, and solving real-world problems with custom tooling. It successfully migrated over 3,000 songs from my personal library with high accuracy and detailed logging.

Key Features

Spotify Export (Go)

  • Fetches all liked songs using official Spotify API
  • Handles OAuth 2.0 authentication automatically
  • Paginates through large libraries (50 songs per request)
  • Exports structured JSON with complete metadata
  • Supports libraries of any size (tested with 3,254+ songs)

YouTube Music Import (Python)

  • Searches and likes songs on YouTube Music
  • Uses browser session authentication
  • Implements rate limiting to avoid API blocks
  • Logs unmatched songs for manual review
  • Progress tracking with detailed console output

Architecture & Design

Two-Part Architecture

The project is split into two independent programs that communicate through a JSON file. This design choice provides flexibility, reliability, and the ability to use the best language for each task - Go for efficient API calls and Python for YouTube Music integration.

spotify-to-ytmusic/
ā”œā”€ā”€ spotify/              # Go program
│   ā”œā”€ā”€ main.go          # Spotify API integration
│   ā”œā”€ā”€ go.mod           # Dependencies
│   └── .env             # API credentials
ā”œā”€ā”€ youtube/             # Python script  
│   ā”œā”€ā”€ main.py          # YouTube Music integration
│   ā”œā”€ā”€ requirements.txt # Python dependencies
│   └── headers_auth.json # Browser session data
└── spotify_liked.json   # Shared data format

Security & Privacy

  • All sensitive files (.env, headers_auth.json) are gitignored
  • Uses official APIs where available (Spotify)
  • Browser session authentication for YouTube Music
  • No data sent to external services - purely local operation
  • Complete transparency with open-source code

Technical Implementation

Spotify Integration (Go)

The Go program handles OAuth 2.0 authentication with Spotify and efficiently fetches large music libraries through paginated API calls.

// Key features implemented:
• OAuth 2.0 flow with PKCE
• Paginated API requests (limit 50 per call)
• JSON marshaling with proper struct tags  
• Error handling and rate limiting
• Environment variable configuration

YouTube Music Integration (Python)

The Python script uses ytmusicapi to search for songs and like them, with sophisticated matching algorithms and error handling.

# Key features implemented:
• Browser session authentication
• Fuzzy song matching algorithms
• Rate limiting (0.3s between requests)
• Progress tracking and logging
• Unmatched song collection for review

Setup & Configuration

Spotify API Setup

1. Create a Spotify Developer app at developer.spotify.com

2. Add redirect URI: http://127.0.0.1:3000/callback

3. Copy credentials to spotify/.env

SPOTIFY_ID=your_spotify_client_id
SPOTIFY_SECRET=your_spotify_client_secret

YouTube Music Authentication

1. Open YouTube Music in Chrome while logged in

2. Open DevTools → Network tab, refresh page

3. Filter by "player" and copy request headers

4. Save headers to youtube/headers_auth.json

Usage Examples

Step 1: Export from Spotify

cd spotify
go run .

# Output:
# Opens Spotify login in browser
# Fetches all liked songs with pagination
# Saves to spotify_liked.json (e.g., 3,254 tracks)

Step 2: Import to YouTube Music

cd youtube
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python main.py

# Output:
# [1] Liked: DUMBO by Travis Scott
# [2] Liked: LOCO by Yeat
# [3] Liked: Sicko Mode by Travis Scott
# ...
# āœ… Successfully migrated 3,182/3,254 songs
# āš ļø  72 unmatched songs saved to unmatched.json

Performance & Results

3,254
Songs Exported
3,182
Successfully Migrated
97.8%
Success Rate
~45min
Total Migration Time

Migration tested on a personal library of 3,254 liked songs with excellent success rate and detailed logging of any unmatched tracks.

Learning Outcomes

Technical Skills

  • OAuth 2.0 implementation in Go
  • REST API integration and pagination
  • Cross-language data sharing via JSON
  • Python web scraping and API usage
  • Rate limiting and error handling
  • Environment configuration and security

Project Management

  • Solving personal problems with custom tools
  • Choosing appropriate languages for each task
  • Documentation and user experience design
  • Security-conscious development practices
  • Open-source project structure and licensing
  • Real-world testing with large datasets

Project Impact

This project solved a real personal need during my transition from Spotify to YouTube Music Premium. By building a custom solution, I avoided paying for migration services while gaining full control over the process and learning valuable API integration skills.

The open-source nature of the project means others facing the same transition can benefit from this free alternative to paid services. The comprehensive documentation and error handling make it accessible to users with varying technical backgrounds.