Transfer Playlists from YouTube Music to Spotify
Project description
YouTube Music To Spotify
An open-source app for effortlessly transferring playlists from YouTube Music to Spotify.
Features
- No limit on size of playlist
- Support public playlists
- Support private playlists
- Auto create or update playlist if it already exists
- Use fuzzy search to find the best match
- Copy playlist thumbnail from youtube to spotify
- Copy playlist description from youtube to spotify
- Limit number of songs to be imported in the playlist
- Dry run mode to test without adding to spotify
Setup
Spotify Developer Account
- Create a new app: https://developer.spotify.com/dashboard
- Set "Redirect URI" to
http://localhost:8888/callback
- Copy the "Client ID" and "Client Secret" to use later
- Copy the "User ID" from your Spotify account: https://www.spotify.com/in-en/account/profile/
Installation
Download the latest version from the releases page.
[!NOTE]
Windows: Windows Defender may interrupt the app from running. Click on more info and allow the program to run.Linux: You need to run the app from terminal, if you want the to know the progress of the transfer.
Spotify Settings
When you run the executable, you will be prompted to enter your Spotify credentials.
Youtube Settings
If you click on "Private Playlist", you will be prompted to enter get your Youtube OAuth credentials if not already set.
[!TIP]
If you find this project useful or interesting, please consider giving it a 🌟star! It helps others discover it too!
GUI
Python3 is required to run the app. You can download it from python.org for Windows.
Install Dependencies
pip install -r requirements.txt
Run the App
python ytm2spt.py
CLI
Setting Environment Variables Linux and Mac
- Rename the file
.env.sample
to.env
- Edit the file by adding your credentials
- Run the following command to set your environment variable:
source .env
Setting Environment Variables (Windows)
- Edit
env.bat
file by adding your credentials in these linesset SPOTIFY_USER_ID=<your_user_id> set SPOTIFY_CLIENT_ID=<your_client_id> set SPOTIFY_CLIENT_SECRET=<your_client_secret>
- Run the batch file to set your environment variable:
env.bat
[!NOTE]
If the environment variables are not set, you may need to restart your terminal or IDE.
Install Dependencies
pip install -r requirements.txt
Youtube OAuth (Only for private playlists)
Run the following command to login to your Youtube account and save the credentials to oauth.json
ytmusicapi oauth
Usage
$ source .env
$ python ytm2spt.py -h
usage: main.py [-h] -yt YOUTUBE_URL_OR_ID
[-sp SPOTIFY_URL_OR_ID | -spname SPOTIFY_PLAYLIST_NAME]
[-ytauth YOUTUBE_OAUTH_JSON]
[-n | -d] [-l LIMIT]
options:
-h, --help show this help message and exit
-yt YOUTUBE_URL_OR_ID, --youtube-url-or-id YOUTUBE_URL_OR_ID
Youtube Playlist URL or ID
-sp SPOTIFY_URL_OR_ID, --spotify-url-or-id SPOTIFY_URL_OR_ID
Spotify Playlist URL or ID
-spname SPOTIFY_PLAYLIST_NAME, --spotify-playlist-name SPOTIFY_PLAYLIST_NAME
Spotify Playlist Name (Default: Youtube Playlist Name)
-ytauth YOUTUBE_OAUTH_JSON, --youtube-oauth-json YOUTUBE_OAUTH_JSON
Youtube OAuth JSON filepath (run 'ytmusicapi oauth')
-n, --create-new Force create a new playlist
-d, --dryrun Do not add to Spotify
-l LIMIT, --limit LIMIT
Limit the number of songs to fetch
Examples
Sample Playlist: Pop Certified (YouTube Music to Spotify)
# Pass any link containing a youtube playlist ID
# Sets same name as youtube playlist
$ python ytm2spt.py -yt "https://music.youtube.com/playlist?list=RDCLAK5uy_lBNUteBRencHzKelu5iDHwLF6mYqjL-JU"
# Pass just the youtube playlist ID
# Set a custom name for the playlist
$ python ytm2spt.py -yt "CLAK5uy_lBNUteBRencHzKelu5iDHwLF6mYqjL-JU" -spname "Pop Certified"
# Pass link of a private youtube playlist
# Provide the path to the oauth.json file
$ python ytm2spt.py -yt "https://music.youtube.com/playlist?list=PLz96m0PSfi9p8ABcEcUlSMVmz7sN-IEFu" -ytauth "oauth.json"
# Pass an existing spotify playlist URL or ID
# Limit the number of songs to fetch
# Dry run mode
$ python ytm2spt.py -yt "CLAK5uy_lBNUteBRencHzKelu5iDHwLF6mYqjL-JU" -sp "https://open.spotify.com/playlist/6DyIxXHMwuEMbsfPTIr9C8" -l 10 -d
# Pass even the URL of video playing from playlist
# Force create a new playlist
$ python ytm2spt.py -yt "https://www.youtube.com/watch?v=RlPNh_PBZb4&list=RDCLAK5uy_lBNUteBRencHzKelu5iDHwLF6mYqjL-JU" -n
Build an Executable
Note: This is only required if you want to build the executable yourself. This is not necessary if you just need to run the app directly using Python.
Requirements:
- C Compiler (gcc, clang)
patchelf
(Linux only)python3-devel
or similar package in your OS
pip install -r requirements-dev.txt
nuitka ytm2spt.py
[!NOTE]
Forked from @edgarh22's Youtube-to-Spotify-Archiver.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ytm2spt-1.1.0.tar.gz
.
File metadata
- Download URL: ytm2spt-1.1.0.tar.gz
- Upload date:
- Size: 321.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3310efbd13eb7a234263981cee2cc898b8929b19a2c551e8a01a5dc456a6c0b2 |
|
MD5 | f87c42d6b8a9893b14254af5269ace36 |
|
BLAKE2b-256 | 333df3c0c5f6535b979bdca28f4199643230aea019308aadfc172083c01ce782 |
File details
Details for the file ytm2spt-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: ytm2spt-1.1.0-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ee095611fd1bc4138b33e74272e71cc9d46109a5ed83e535ad33d39f81f8b08 |
|
MD5 | 01633e51e45eeaba65edc1aabf770ec8 |
|
BLAKE2b-256 | 73177b61ccca90a3c00a866c34c111f254a7c3ec89c3ad6a8710dad8954b4894 |