This is a small python code that I use with my NAS server connected to Plex

Overview

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 
Comments
  • Nothing happens

    Nothing happens

    Running on windows 10, Installed everything in the requirements.txt with python 3.9.7.

    I double click the main.py, command prompt opens and closes immediately. Only thing in the log_spotifarr is

    Log of [2021-10-20 16:42:28.731298]

    question 
    opened by aporzio1 24
  • Emojis in playlist names breaks the script

    Emojis in playlist names breaks the script

    Lets say you have the emoji 🍹in your playlist name unicode \U0001f379 it would break the script with the following error

    UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f379' in position 37: character maps to <undefined>
    
    bug 
    opened by GoByeBye 16
  • Cant run

    Cant run

    When I run python3 main.py i get this error

    Traceback (most recent call last): File "main.py", line 4, in from modules.plex import * File "/home/administrator/sp/Spotifarr/modules/plex.py", line 3, in from plexapi.server import PlexServer ModuleNotFoundError: No module named 'plexapi'

    opened by Coolgam3r2152 1
  • Error

    Error

    I am seeing this error.

    (venv) dulanic@mediaserver:~/git/Spotifarr$ python main.py
    
    Updating the playlists
    
     Updating database with 3 playlists: [UUU]
    Updating the locations
    
     My Playlist with 40: [========================================]
     Goodbye Octane with 1102: [Traceback (most recent call last):
      File "main.py", line 13, in <module>
        build_track_location()
      File "/home/dulanic/git/Spotifarr/modules/youtube_to_mp3.py", line 71, in build_track_location
        location = location_file(name, ps[2])
      File "/home/dulanic/git/Spotifarr/modules/config_handler.py", line 26, in location_file
        for (dir, subdirs, files) in os.walk(path):
      File "/usr/lib/python3.8/os.py", line 339, in walk
        top = fspath(top)
    TypeError: expected str, bytes or os.PathLike object, not NoneType
    
    opened by Dulanic 1
  • Doesn;t create folder is not exists

    Doesn;t create folder is not exists

    Ran into this error....

    
     Updating database with 3 playlists: [Traceback (most recent call last):
      File "/home/dulanic/git/Spotifarr/main.py", line 9, in <module>
        spotify_c().update_playlists()
      File "/home/dulanic/git/Spotifarr/modules/spotify_db.py", line 82, in update_playlists
        "location": location_folder(clean_up_text(playlist['name']), self.path_music),
      File "/home/dulanic/git/Spotifarr/modules/config_handler.py", line 21, in location_folder
        os.mkdir(folder_playlist)
    FileNotFoundError: [Errno 2] No such file or directory: '/mnt/btrfs/music/My Playlist'
    (venv) abc@680a903a76d6:/home/dulanic/git/Spotifarr$ 
    
    opened by Dulanic 1
  • Does not grab all playlists

    Does not grab all playlists

    The script seems to grab the playlists I have created; however, it does not grab playlists that I am subscribed to, or playlists that I have created and then made into collaborative playlists. Can these be added?

    opened by goose-ws 2
  • Wont update playlists

    Wont update playlists

    Everytime I run the script it keeps showing the same playlists and wont update the playlist from the account. I tried changing the client key but that didn't fix it. Even after I checked the keys to all be correct. It there a known fix?

    opened by Coolgam3r2152 0
  • unsupported operand type(s)

    unsupported operand type(s)

    Hello, I'm getting this error. Any help is appreciated.

    Download missing Traceback (most recent call last): File "C:\Users\Server\Desktop\spotifarr\main.py", line 24, in download_missing() File "C:\Users\Server\Desktop\spotifarr\modules\youtube_to_mp3.py", line 99, in download_missing if music(track[1] + " - " + track[0]).download_in(ps[2],i,ps[0]): File "C:\Users\Server\Desktop\spotifarr\modules\youtube_to_mp3.py", line 39, in download_in self.option['outtmpl'] = path_to_save + "/" + self.video_title + '.%(ext)s' TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

    opened by mcn18 1
  • IndexError: list index out of range

    IndexError: list index out of range

    Me again!

    Running the tool this morning after a first successful run last night, I'm now encountering this issue - I pull down the first video and then received the following error:

    `Traceback (most recent call last):
      File "C:\Users\jedi9\Documents\Spotifarr-main\main.py", line 24, in <module>
        download_missing()
      File "C:\Users\jedi9\Documents\Spotifarr-main\modules\youtube_to_mp3.py", line 99, in download_missing
        if music(track[1] + " - " + track[0]).download_in(ps[2],i,ps[0]):
      File "C:\Users\jedi9\Documents\Spotifarr-main\modules\youtube_to_mp3.py", line 52, in download_in
        video_url = videosSearch.result()['result'][0]['link']
    IndexError: list index out of range`
    
    
    opened by Iyagovos 4
  • Create Plex playlist without downloading

    Create Plex playlist without downloading

    This is a great tool and something I have been looking for. Wondering if it is possible to just match the existing files in Plex and create a playlist. Something that would just transfer the playlist from Spotify to Plex and match whatever tracks that can be matched. Bonus points, if it can highlight which tracks were not matched.

    enhancement 
    opened by arsaboo 2
Owner
Automator
Automator
A simple python script that parses the MSFT Teams log file for the users current Teams status and then outputs the status color to a MQTT connected light.

Description A simple python script that parses the MSFT Teams log file for the users current Teams status and then outputs the status color to a MQTT

Lorentz Factr 8 Dec 16, 2022
High capacity, high availability, well connected, fast lightning node.

LND ⚡ Routing High capacity, high availability, well connected, fast lightning node. We aim to become a top liquidity provider for the lightning netwo

null 18 Dec 16, 2022
This tool will scans your wi-fi/wlan and show you the connected clients

This tool will scans your wi-fi/wlan and show you the connected clients

VENKAT SAI SAGAR 3 Mar 24, 2022
IP Pinger - This tool allows you to enter an IP and check if its currently connected to a host

IP Pinger - This tool allows you to enter an IP and check if its currently connected to a host

invasion 3 Feb 18, 2022
A TCP Chatroom built with python and TCP/IP sockets, consisting of a server and multiple clients which can connect with the server and chat with each other.

A TCP Chatroom built with python and TCP/IP sockets, consisting of a server and multiple clients which can connect with the server and chat with each other. It also provides an Admin role with features including kicking and baning of users.

null 3 May 22, 2022
Test - Python project for Collection Server and API Server

QProjectPython Collection Server 와 API Server 를 위한 Python 프로젝트 입니다. [FastAPI참고]

null 1 Jan 3, 2022
This is a Client-Server-System which can share the screen from the server to client and in the other direction.

Screenshare-Streaming-Python This is a Client-Server-System which can share the screen from the server to client and in the other direction. You have

VFX / Videoeffects Creator 1 Nov 19, 2021
This is a Client-Server-System which can send audio from a microphone from the server to client and in the other direction.

Audio-Streaming-Python This is a Client-Server-System which can send audio from a microphone from the server to client and in the other direction. You

VFX / Videoeffects Creator 0 Jan 5, 2023
An ftp syncing python package that I use to sync pokemon saves between my hacked 3ds running ftpd and my server

Sync file pairs over ftp and apply patches to them. Useful for using ftpd to transfer ROM save files to and from your DS if you also play on an emulator. Setup a cron job to check for your DS's ftp server periodically to setup automatic syncing. Untested on windows. It may just work out of the box, unsure though.

null 17 Jan 4, 2023
Very simple FTP client, sync folder to FTP server, use python, opensource

ftp-sync-python Opensource, A way to safe your data, avoid lost data by Virus, Randsomware Some functions: Upload a folder automatically to FTP server

null 4 Sep 13, 2022
A simple software which can use to make a server in local network

home-nas it is simple software which can use to make a server in local network, it has a web site on it which can use by multipale system, i use nginx

R ansh joseph 1 Nov 10, 2021
IoT owl is light face detection and recognition system made for small IoT devices like raspberry pi.

IoT Owl IoT owl is light face detection and recognition system made for small IoT devices like raspberry pi. Versions Heavy with mask detection withou

Ret2Me 6 Jun 6, 2022
stellar-add-guest is a small tool to generate a new guest for Stellar Wireless (Enterprise mode) in OmniVista 2500 hosted on OmniSwitch with AOS Release 8

stellar-add-guest is a small tool to generate a new guest for Stellar Wireless (Enterprise mode) in OmniVista 2500 hosted on OmniSwitch with AOS Release 8.

BennyE 3 Jan 24, 2022
A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio.

asyncio-socks-server A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio. Features Supports both TCP a

Amaindex 164 Dec 30, 2022
Extended refactoring capabilities for Python LSP Server using Rope.

pylsp-rope Extended refactoring capabilities for Python LSP Server using Rope. This is a plugin for Python LSP Server, so you also need to have it ins

null 36 Dec 24, 2022
A simple DHCP server and client simulation with python

About The Project This is a simple DHCP server and client simulation. I implemented it for computer network course spring 2021 The client can request

shakiba 3 Feb 8, 2022
Simple threaded Python Rickroll server. Listens on port 23 by default.

Terminal Rickroll Simple threaded Python Rickroll server. Listens on port 23 by default. Rickroll video made using Video-To-Ascii and the standard ric

AG 10 Sep 13, 2022
Python implementation of the Session open group server

API Documentation CLI Reference Want to build from source? See BUILDING.md. Want to deploy using Docker? See DOCKER.md. Installation Instructions Vide

Oxen 36 Jan 2, 2023
🎥 PYnema is a simple UDP server written in python, allows you to watch downloaded videos.

?? PYnema is a simple UDP server written in python, allows you to watch downloaded videos.

Jan Kupczyk 1 Jan 16, 2022