Version: 1.1
Date: 2024-10-28
Author: ergosteur (LLM assisted)
convert_playlist_aio_plex_spotify_youtube.py
is a versatile Python script designed to sync playlists between Spotify, YouTube Music, and Plex. It supports multiple sync directions (e.g., Spotify to Plex, Plex to YouTube Music) with options for exact or fuzzy album matching and conflict management, preventing duplicate additions. The script can create new playlists or update existing ones, handling various platform-specific quirks seamlessly.
This script depends on the following libraries:
requests
spotipy
ytmusicapi
plexapi
Install these dependencies with:
pip install requests spotipy ytmusicapi plexapi
The script requires several command-line arguments to specify the source and destination services, playlist details, and other options.
--source-service
(required): Source platform for the playlist (spotify
,ytmusic
, orplex
).--destination-service
(required): Destination platform for the playlist (plex
,spotify
, orytmusic
).--playlist-url
(optional): URL of the source playlist (required only for Spotify and YouTube Music).--playlist-name
: Name of the destination playlist.--cookies-path
: Path tocookies.txt
for Spotify API access.--yt-oauth-json
: Path to YouTube Music OAuth JSON file.--plex-url
: URL of your Plex server.--plex-token
: Plex authentication token.--append
: Append to an existing playlist (if it exists).--replace
: Replace an existing playlist (if it exists).--unmatched-output
: Path to save unmatched track details.--unmatched-format
: Format of the unmatched output file (text
orcsv
, default istext
).--verbose
or-v
: Enable verbose output for detailed feedback.
- Download and Install: Use the browser extension Get cookies.txt for Chrome or Firefox to export your cookies.
- Login to Spotify: Open Spotify in your browser and log in to your account.
- Export cookies: Click the extension icon and export cookies from the
open.spotify.com
domain. Save the file ascookies.txt
in the desired location. - Use
--cookies-path
: Specify the path to this file using the--cookies-path
argument.
- Install
ytmusicapi
CLI: Run the following command:python -m ytmusicapi oauth
- Follow the Authentication Process: This command will open a browser for Google account authentication. Follow the steps to grant
ytmusicapi
access. - Save the File: After successful authentication, an
oauth.json
file will be created. Use this file as the path for the--yt-oauth-json
argument.
python convert_playlist_aio_plex_spotify_youtube.py --source-service spotify --destination-service ytmusic --playlist-url "https://open.spotify.com/playlist/your_spotify_playlist_id" --yt-oauth-json path/to/ytmusic_oauth.json --playlist-name "Synced Playlist" --verbose
python convert_playlist_aio_plex_spotify_youtube.py --source-service spotify --destination-service plex --playlist-url "https://open.spotify.com/playlist/your_spotify_playlist_id" --plex-url "http://your_plex_server:32400" --plex-token "your_plex_token" --playlist-name "Synced Playlist" --verbose
python convert_playlist_aio_plex_spotify_youtube.py --source-service ytmusic --destination-service spotify --playlist-url "https://music.youtube.com/playlist?list=your_ytmusic_playlist_id" --cookies-path path/to/spotify_cookies.txt --playlist-name "Synced Playlist" --verbose
python convert_playlist_aio_plex_spotify_youtube.py --source-service ytmusic --destination-service plex --playlist-url "https://music.youtube.com/playlist?list=your_ytmusic_playlist_id" --plex-url "http://your_plex_server:32400" --plex-token "your_plex_token" --playlist-name "Synced Playlist" --verbose
python convert_playlist_aio_plex_spotify_youtube.py --source-service plex --destination-service spotify --playlist-name "Synced Playlist" --cookies-path path/to/spotify_cookies.txt --verbose
python convert_playlist_aio_plex_spotify_youtube.py --source-service plex --destination-service ytmusic --playlist-name "Synced Playlist" --yt-oauth-json path/to/ytmusic_oauth.json --verbose
- convert_playlist_xx_yy.py : Single-purpose scripts. Superseded by the aio script, but provided for posterity.
- get_spotify_playlist.py : simply prints a Spotify playlist to stdout in text format.
- search_plex_trac: test of recursive search in the Plex music library.
This script merely ties together the work of the talented developers behind these excellent Python api libraries:
- v1.0: Initial version with basic syncing functionality.
- v1.1: Minor bug fixes.