Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Miggrer

Migrate your Spotify Liked Songs to YouTube Music automatically.

Stars License Last commit Python 3.7+

Features · Quick Start · Auth Methods · Scripts · Configuration · Tech Stack


Miggrer reads your Spotify Liked Songs CSV export, searches for each track on YouTube Music, and adds matching songs to a new playlist called "Liked Songs (Spotify)" — fully automatic with retry logic, batch processing, and crash-safe resume.

Features

Feature Description
Spotify CSV Import Reads your liked songs from a standard Spotify CSV export
YouTube Music Search Automatically finds matching tracks on YouTube Music
Playlist Creation Creates a "Liked Songs (Spotify)" playlist if it doesn't exist
Batch Processing Saves tracks in batches of 10 to reduce API calls
Retry with Backoff Retries failed tracks up to 3 times with exponential backoff
Auto Token Refresh Refreshes SAPISIDHASH authorization every 120 seconds
Crash-Safe Resume Persists processed tracks to resume after interruption
Two Auth Methods Choose between Browser/Cookie or OAuth authentication

Quick Start

1. Clone the Repository

git clone https://github.com/Beno-Goulart/Miggrer.git
cd Miggrer

2. Install Dependencies

pip install -r requirements.txt

3. Export Your Spotify Liked Songs

  1. Go to Spotify Account Data
  2. Request an "Account data" download
  3. Find the Liked_Songs CSV inside the exported ZIP
  4. Place it in the project root

4. Set Up Authentication

Choose one method: Browser/Cookie or OAuth.

5. Run the Migration

# Cookie-based migration
python src/migrador.py

# OAuth-based migration (with resume support)
python src/migrador_oauth.py

Auth Methods

Browser/Cookie Method

Uses cookies from your browser session. Simpler to set up, but tokens expire.

Setup

  1. Log into YouTube Music in Chrome
  2. Open DevTools (F12) → Network tab
  3. Reload the page, click any request to music.youtube.com
  4. Copy the raw request headers
  5. Run the interactive updater:
python src/utils/atualizar_browser.py
  1. Paste the headers when prompted, press Enter twice to finish

This generates data/browser.json with the required authentication credentials.

OAuth Method

Uses Google OAuth2. More robust, supports automatic token refresh.

Setup

  1. Create a Google Cloud project
  2. Enable the YouTube Data API v3
  3. Create OAuth 2.0 credentials (Desktop app type)
  4. Set environment variables:
# Windows PowerShell
$env:GOOGLE_CLIENT_ID="your_client_id"
$env:GOOGLE_CLIENT_SECRET="your_client_secret"

# Linux/macOS
export GOOGLE_CLIENT_ID="your_client_id"
export GOOGLE_CLIENT_SECRET="your_client_secret"

Or copy .env.example to .env and fill in the values.

  1. Run the OAuth setup:
python src/utils/setup_oauth.py
  1. A browser window opens — authorize with your Google account
  2. Credentials are saved to data/oauth.json

Scripts

Script Description
src/migrador.py Main migration script using browser cookie auth
src/migrador_oauth.py Alternative migration using OAuth (with crash-safe resume)
src/utils/setup_oauth.py One-time OAuth token generator
src/utils/gerar_headers.py Generates browser.json from raw headers
src/utils/atualizar_browser.py Interactive CLI tool to update browser.json from DevTools

Configuration

Environment Variables (OAuth method)

Variable Description
GOOGLE_CLIENT_ID Your Google Cloud OAuth 2.0 client ID
GOOGLE_CLIENT_SECRET Your Google Cloud OAuth 2.0 client secret

Data Files

File Purpose
data/browser.json YouTube Music browser auth credentials (cookie-based)
data/oauth.json OAuth token (generated by setup_oauth.py)
data/processed.json Tracks already migrated (auto-managed, enables resume)

Project Structure

Miggrer/
├── src/
│   ├── migrador.py                # Main migrator (cookie auth)
│   ├── migrador_oauth.py          # Alternative migrator (OAuth auth)
│   └── utils/
│       ├── setup_oauth.py         # OAuth setup helper
│       ├── gerar_headers.py       # Browser JSON generator
│       └── atualizar_browser.py   # Interactive header updater
├── data/
│   ├── browser.json               # Browser auth credentials (gitignored)
│   ├── oauth.json                 # OAuth token (gitignored)
│   └── processed.json             # Migrated tracks (gitignored)
├── docs/
│   └── logo.png
├── .env.example
├── .gitignore
├── requirements.txt
└── README.md

Tech Stack

Component Technology
Language Python 3.7+
YouTube Music API ytmusicapi
Auth (Browser) Cookie-based SAPISIDHASH
Auth (OAuth) Google OAuth 2.0
CSV Parsing Python csv (stdlib)
Data Storage JSON files

License

MIT — use it, fork it, migrate it.

About

Automatic migration of Spotify songs to YouTube Music via Python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages