Spotifarr

This is a small python code that I use with my NAS server connected to Plex
I didn’t appreciate how Lidarr works because it downloads a full Album. So I created something on my own.

Way of working

  • The python script will connect to your Spotify and will retrieve your playlists using spotipy package
  • The python script will create an SQL database with your playlist & the list of tracks
  • The python script will then search a youtube video based on the name & the artist gathered from the metadata
  • The python script will download the video in .mp3 using youtube-dl package
  • The python script will update the metadata and prepare it for plex using mutagen
  • Finally, the python script will trigger an update and will create the same playlist that is in your Spotify in plex using PlexAPI

Configuration

To make the script work you need to configure the document credentials.json

  • “username”: “your spotify username found in Overview

You need then to create a spotify APP – Spotify for developers to retrieve both of these parameters 

  • “client_id”: “”,
  • “client_secret”: “”,

Define the location of where you will save your media (for me I used /media/Music )

  • “path_music”: “”,

(Optional) You can create a password app to allow youtube-dl to download explicit music, else you can leave it blank

  • “ytb_username”: “”,
  • “ytb_password”: “”,

Now to configure plex you need to enter the base URL for example http://localhost:32400/ and for the token, you can follow-up Plex tutorial 

  • “plex_base_url”: “”,
  • “plex_token”: “”

Requirements

If you are running on windows you can install all the pip found in the requirement.txt

Else on FreeBSD you need to install:

pkg install python, py38-sqlite3

Run

Now you only have to run main.py and enjoy

 

 

PS:

  1. I tried to create a web interface using FLASK but I’m still in the learning process. So sorry for that.
  2. If you want to have daily monitoring you can add a corn job for main.py and 
  3. I created this for fun and not for business use. I am always enrolled in Spotify premium services but I just wanted to try. So please I do not encourage any prohibited behavior 

GitHub

View Github