Sync your music playlists between Spotify and YouTube Music with AI-powered track matching using Google Gemini.
- π Bidirectional Sync: Transfer music from Spotify β YouTube Music
- π€ AI Matching: Google Gemini 2.0 Flash for intelligent semantic track recognition
- β‘ Parallel Processing: 5 concurrent workers for fast matching
- π¨ Beautiful UI: Dark glassmorphism design with gradient effects
- π Real-time Progress: Live matching progress with cancel option
- βοΈ Custom Playlist Names: Name your synced playlists
- π― Smart Filtering: Review matched, low confidence, and not found tracks
- π« No Duplicates: Automatic duplicate detection
- πΎ Match Caching: Cached matches for faster repeat syncs (optional)
- Framework: Next.js 16 (App Router, Turbopack) + TypeScript
- Styling: Tailwind CSS
- Authentication: iron-session + OAuth2
- Spotify API: @spotify/web-api-ts-sdk
- YouTube: googleapis (writes) + ytmusic-api (reads/search)
- AI Matching: Google Gemini 2.0 Flash
- Database: Prisma + SQLite (PostgreSQL for production)
- Deployment: Vercel / Docker
-
Spotify Developer Account
- Go to Spotify Developer Dashboard
- Create a new app
- Note your Client ID and Client Secret
- Add redirect URI:
http://localhost:3000/auth/spotify/callback
-
Google Cloud Project (for YouTube)
- Go to Google Cloud Console
- Create a new project
- Enable YouTube Data API v3
- Create OAuth 2.0 credentials (Web application)
- Add redirect URI:
http://localhost:3000/auth/youtube/callback - Note your Client ID and Client Secret
-
Google Gemini API (for AI matching)
- Go to Google AI Studio
- Create an API key
- Note your API key
-
Install dependencies:
npm install
-
Configure environment variables: Edit
.env.localand fill in your credentials:# Spotify OAuth SPOTIFY_CLIENT_ID=your_spotify_client_id_here SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here SPOTIFY_REDIRECT_URI=http://localhost:3000/auth/spotify/callback # YouTube / Google OAuth GOOGLE_CLIENT_ID=your_google_client_id_here GOOGLE_CLIENT_SECRET=your_google_client_secret_here GOOGLE_REDIRECT_URI=http://localhost:3000/auth/youtube/callback # Session encryption (generate with: openssl rand -base64 32) SESSION_SECRET=your_32_character_or_longer_secret_here # App URL NEXT_PUBLIC_APP_URL=http://localhost:3000 # Google Gemini API (for AI matching) GEMINI_API_KEY=your_gemini_api_key_here
Generate a secure session secret:
openssl rand -base64 32
-
Initialize the database:
npx prisma generate npx prisma db push
-
Start the development server:
npm run dev
-
Open the app: Navigate to http://localhost:3000
- Click "Get Started" on the landing page
- Connect both Spotify and YouTube Music accounts via OAuth
- You must connect both accounts to start syncing
- Click "Start Sync" once both accounts are connected
- Choose direction: YouTube β Spotify or Spotify β YouTube
- Check the playlists you want to sync
- View total track count
- Wait for the matching engine to process all tracks
- Review matched tracks with confidence scores
- Filter by: Matched, Low Confidence, Not Found, Already Exists
- Confirm and sync your tracks
- A new playlist is created on the target platform
- View results summary with added/failed counts
The matching engine uses Google Gemini 2.0 Flash AI for intelligent track matching:
- Search: Searches target platform (Spotify/YouTube) for candidate tracks
- AI Analysis: Gemini AI semantically analyzes:
- Title variations ("Official Video", "Remaster", "Live", etc.)
- Artist name differences (VEVO suffix, featuring artists, name order)
- Duration similarity (Β±10 seconds acceptable)
- Parallel Processing: Processes 5 tracks simultaneously for speed
- Confidence Scoring:
- β₯70% = Matched (green) - High confidence match
- <70% = Low Confidence (yellow) - Possible match, review recommended
- No match = Not Found (red) - Track not available
- Semantic Understanding: Understands context, not just string similarity
- Handles Variations: "Billie Eilish - lovely (with Khalid)" = "lovely - Billie Eilish ft. Khalid"
- Smart: Recognizes remasters, live versions, and different editions
- Fast: Parallel processing with 5 concurrent workers
- Cheap: ~$0.006 per 100 songs (free experimental version currently)
- SyncHistory: Records of all sync operations
- MatchRecord: Individual track match details
- MatchCache: Cached matches (30-day TTL) for faster repeat syncs
- Spotify: 30-second rolling window (handled automatically with retries)
- YouTube Data API: 10,000 quota units/day
- Playlist insert = 50 units (max ~200 adds/day)
- Search = 100 units (we use ytmusic-api to avoid this)
- ytmusic-api: No official limits (unofficial scraper)
src/
βββ app/ # Next.js App Router pages
β βββ api/ # API routes
β βββ auth/ # OAuth callbacks
β βββ dashboard/ # Main dashboard
β βββ sync/ # 4-step sync wizard
βββ lib/ # Core logic
β βββ spotify/ # Spotify API client
β βββ youtube/ # YouTube API clients
β βββ matching/ # Fuzzy matching engine
β βββ sync/ # Sync utilities
β βββ session.ts # iron-session config
β βββ db.ts # Prisma client
prisma/
βββ schema.prisma # Database schema
- Make sure you've filled in
SPOTIFY_CLIENT_ID,SPOTIFY_CLIENT_SECRETin.env.local - Check that the redirect URI in your Spotify app matches exactly
- Verify
GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRETin.env.local - Ensure YouTube Data API v3 is enabled in Google Cloud Console
- Check redirect URI matches exactly
- The track might not exist on the target platform
- Try with well-known popular tracks first to test
- Check the console for API errors
- YouTube Data API has a 10,000 units/day limit
- Each playlist insert costs 50 units (max ~200 songs/day)
- Wait until the next day or request a quota increase from Google
Run in development mode:
npm run devBuild for production:
npm run build
npm startView database:
npx prisma studioSee DEPLOYMENT.md for comprehensive deployment guide.
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prodImportant: Set all environment variables in Vercel Dashboard and update OAuth redirect URIs to your production domain.
# Build image
docker build -t spotifyt .
# Run container
docker run -p 3000:3000 --env-file .env.production spotifyt- Update all redirect URIs to production domain
- Generate new SESSION_SECRET for production
- Add environment variables in your hosting platform
- Update OAuth apps in Spotify and Google Cloud Console
- Spotify API: Free
- YouTube API: Free (using ytmusic-api scraper)
- Gemini AI: Free experimental version
- Gemini 2.0 Flash:
$0.006 per 100 songs ($0.06 per 1,000 songs)
MIT
Built with: