Skip to content

yogeshwaran01/spotify-playlist-to-youtube-playlist

Repository files navigation

Spot2Tube

Convert Spotify Playlist to YouTube Playlist

image

GitHub stars GitHub forks GitHub license Code style GitHub Repo size

About

Python script to convert Spotify playlist to YouTube playlist.

Features

  1. Convert Spotify playlist to YouTube Playlist
  2. Sync YouTube Playliset with Spotify playlist Sync Multiple Playlists

Setup

Requirements

  1. Install Python (https://www.python.org/)
  2. Install all required package (After cloning the repo, inside the folder)
pip install -r requirements.txt

YouTube

  1. Go to the Google Cloud Console, sign in with your Google account, and create a new project.
  2. Once your project is created, select it from the project dropdown menu in the top navigation bar.
  3. Go to the Credentials page in the API & Services section of the left sidebar.
  4. Click on the "Create Credentials" button and select "OAuth client ID".
  5. After creating select edit button in the OAuth 2.0 Client IDs, Select application type as Desktop App and then click create.
  6. Click the download button to download the credentials in your project directory. Rename the file to client_secret.json
  7. Go to the OAuth consent screen in the API & Services section of the left sidebar. Under test user add your Gmail id.

Spotify

  1. Go to the Spotify Developer Dashboard and log in with your Spotify account.
  2. Click on the "Create an App" button and fill out the necessary information, such as the name and description of your application.
  3. Once you've created the app, you'll be taken to the app dashboard. Here, you'll find your client ID and client secret, which are used to authenticate your application with the Spotify API.
  4. Add you client id and secert in .env file
CLIENT_ID="xxxxxxxxxxxxxxxxxx"
CLIENT_SECRET="xxxxxxxxxxxxxxxx"

Usage

Quick Guide

Format

python main.py create [OPTIONS] SPOTIFY_PLAYLIST_ID

Browser will open for authorization. Sign into google account.

Options:

  --public                Create a public playlist
  --private               Create a public playlist
  -n, --name TEXT         Name of the YouTube playlist to be created
  -d, --description TEXT  Description of the playlist
  -l, --only-link         just only link of playlist, logs not appear
  -s, --save-to-sync      Save to list of playlist to sync
  --help                  Show this message and exit. Refer sync-multiple-playlist section in ReadMe

Examples

Create YouTube Playlist from Spotify Playlist

python main.py create SPOTIFY_PLAYLIST_ID
  • Create public YouTube playlist with custom Playlist Title and Description:
python main.py create --public -n "My Playlist" -d "A collection of my favorite songs" SPOTIFY_PLAYLIST_ID
  • Create private YouTube playlist and save it to the list of playlists to sync:
python main.py create --private -s SPOTIFY_PLAYLIST_ID
  • Get only the link of the YouTube playlist without displaying logs:

Sync YouTube Playlist with Spotify playlist

Usage

main.py sync [OPTIONS]
Options:

  -s, --spotify_playlist_id TEXT  Spotify playlist ID
  -y, --youtube_playlist_id TEXT  YouTube playlist ID
  -l, --only-link                 just only link of playlist, logs not appear
  --help                          Show this message and exit.
python main.py sync -s <spotify_playlist_id> -y <youtube_playlist_id>
  • -s, --spotify_playlist_id: Specifies the Spotify playlist ID to sync.
  • -y, --youtube_playlist_id: Specifies the YouTube playlist ID to sync.
  • -l, --only-link: Retrieves only the link of the playlist without displaying logs.

It also open browser for authorization. Sign into google account to sync playlist.

Sync Spotify playlist with YouTube playlist and retrieve only the link:

python main.py sync -s SPOTIFY_PLAYLIST_ID -y YOUTUBE_PLAYLIST_ID --only-link

Sync Multiple playlist

When creating a playlist, just add --save-to-sync or -s flag to it. It save the Spotify and YouTube playlist id in playlists.json file.

Sync all playlists in that file -

python main.py sync

Clear file -

python main.py clear

How this works

Refer this blog post for more info

Contact Me

If you need more info or any support please feel free to contact me

Contributing

Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.

License

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