Skip to content

mcguirepr89/spotimy

Repository files navigation

Spotify to YouTube Playlist Converter 🎵➡️📺

A Python tool that helps you quickly convert a Spotify playlist into a YouTube playlist — and generates a beautiful, mobile-friendly HTML page with all your tracks and links.

Built with Spotipy, Google API, TailwindCSS, and lots of love. ❤️


Features ✨

  • 🔄 Convert a Spotify playlist into a YouTube playlist automatically
  • 🌐 Generate an HTML page with:
    • Embedded YouTube playlist player
    • Link to the original Spotify playlist
    • Toggleable track list (show/hide)
    • Beautiful responsive design with dark mode
  • 🌓 Dark mode support (follows system preferences)
  • 📜 Simple, clean codebase with easy customization
  • ⚡ Fast and lightweight, no server needed — just open the HTML file!

Screenshots 📸

See my example Spotimy page here

Screenshot 1 Screenshot 2

Requirements:

  • A Spotify Premium account to create an app and access the Spotify WebAPI
  • Goolge account to create an app and access the YouTube Data API v3

Installation ⚙️

  1. Clone the repository:

    git clone https://github.com/mcguirepr89/spotimy.git
    cd spotimy
  2. Create a Spotify Developer App at Spotify Developer Dashboard

    1. Create developer app on the dashboard.

    2. Add a Redirect URI http://127.0.0.1:8888/callback in the app settings.

    3. Copy your Client ID and Client Secret and put them in a .env file like so:

      spotimy/.env:

      SPOTIFY_CLIENT_ID=mylongclientid
      SPOTIFY_CLIENT_SECRET=mylongclientsecret
      
  3. Generate a YouTube Data API v3 key:

    1. Go to the Google Cloud Console.
    2. Enable the YouTube Data API v3.
    3. Generate OAuth 2.0 credentials with https://www.googleapis.com/auth/youtube.force-ssl scope.
    4. Download your client credentials JSON file and rename it client_secret.json
  4. Install dependencies in a virtual environment in the spotimy directory:

    1. python3 -m venv venv && source ./venv/bin/activate
    2. pip install -U pip && pip install -r requirements.txt

Usage 🚀

usage: spotimy.py [-h] [--resume RESUME] [--generate-html] [--spotify-add SPOTIFY_ADD]

Spotify to YouTube playlist converter and web page creator.

options:
  -h, --help            show this help message and exit
  --resume RESUME       Path to a resume JSON file to continue a previous session.
  --generate-html       Generate an HTML page with links and optional embed.
  --spotify-add SPOTIFY_ADD
                        Path to file containing Spotify track IDs for adding to Spotify playlist.

Run the script interactively:

python spotimy.py

You will be prompted to:

  • Choose a Spotify playlist
  • Optionally create a YouTube playlist or select an existing one
  • Export a mobile-friendly HTML page with embedded YouTube links

You can then open the generated youtube_links.html in any web browser!

OR resume from a previous conversion (see Limitations below for why this might be needed/helpful):

python spotimy.py --resume Spotify_playlist-to-Youtube_playlist.json

AND you can add tracks from a tracklist to a new or existing Spotify playlist (see Hints below for tips on using this feature):

python spotimy.py --spotify-add ListOfSpotifyTrackIDs_OR_song_links.txt

Technologies Used 🛠


License 📄

This project is licensed under the MIT License. See the LICENSE file for details.

Known bugs and limitations

Bugs

Since this tool works by adding the first video from the YouTube search of format Track Title - Artist Name (Album: Album Name), mistakes are bound to happen. One problem that seems to be pretty common is that "Full Album" videos get added when a song is also an album name.

Example: Colour Green - Sibylle Baier (Album: Colour Green) adds the video Sibylle Baier - Colour Green (Full Album)

Limitations

The API requests are limited. At the time of writing, (April 14th, 2025), I've only been able to convert 68 Spotify tracks into YouTube playlist items before hitting the API daily rate limit.

Hints

Spotify deprecated being able to get the tracks from their currated playlists. This little javascript code snippet can be used to extract all of the href targets from the <a> tags when you open those playlist pages in your browser, zoom ALLLLL the way out so that every track is loaded and visible, and then dumping those into a file.

const trackLinks = Array.from(document.querySelectorAll('a'))
                        .map(a => a.getAttribute('href'))
                        .filter(href => href && href.includes('track'))
                        .map(href => href.split('/track/')[1]);

console.log(trackLinks.join('\n'));

Example workflow using Chrome:

  1. Go to the playlist in the web browser.
  2. Press Ctrl + Shift + I to enter the browser's web inspector.
  3. Using the element explorer, highlight the <div> element that contains the playlist track listing and right click to "cut" it into your clipboard.
  4. Delete the entire <body> element
  5. Append (paste) the <div> from your clipboard.
  6. Go to the web inspector's "Console" to paste the javascript snippet above.
  7. Copy and paste the results into a text file.

About

Convert Spotify playlist into YouTube playlist

Resources

Stars

Watchers

Forks

Languages