Giter VIP home page Giter VIP logo

ppp's Introduction

PPP

Plex Playlist Pusher (Python Re-write)

Looking for the original Bash version? Find it here


A simple Python 3 script used to automatically:

  • load .m3u playlists from a local directory (maybe your MusicBee library... Can't be the same directory as your PPP installation!)
  • load music playlists from Plex
  • compare the two, merging any new tracks or entire playlists
  • push the updated playlists back to Plex using the Plex Playlist API (https://forums.plex.tv/t/can-plexamp-read-and-use-m3u-playlists/234179/21)
  • copy the updated playlists back to your local directory

This will keep Plex playlists and local playlists synchronised. If you want to delete a playlist or song from a playlist, it must be removed from BOTH local and Plex playlists.


Usage instructions

  1. Install Python 3 if you haven't already
  2. Download the latest release of PPP from here
  3. For first run, see Setup
  4. Run PPP with Python 3
usage: PPP.py [-h] [-setup] [-nobackups] [-retention n] [-nocleanup]

optional arguments:
  -h, --help    show this help message and exit
  -setup        Force-run the setup procedure
  -nobackups    Disable backup of local playlists completely!
  -retention n  Number of previous local playlist backups to keep (Default 10)
  -nocleanup    Disable removal of .tmp directory (for debugging only)

Setup

PPP will guide you through a setup on first run, and attempt to help you find all required variables.

  • Variables are saved to variables.json
  • If needed this can be edited manually

Alternatively rename example-variables.json to variables.json and edit the file manually.


Automation

Linux

Use crontab. You may need to apply this fix.

Example crontab:

* * * * * cd /path/to/PPP && /usr/bin/python3 /path/to/PPP/PPP.py >> /path/to/PPP/PPP.log 2>&1

Windows

Use task scheduler? I haven't tested it.


Variables (Reference)

Running setup should help you find all these variables!

VARIABLE DESCRIPTION EXAMPLE
server_url the url of your Plex server, as seen by whatever you're running PPP on "http://192.168.1.100:32400"
check_ssl validate, or ignore SSL certificate ('"False"' for self signed https) "True"
plex_token find it here "A1B3c4bdHA3s8COTaE3l"
local_playlists path to the local playlists you want to use, relative to PPP "/mnt/Playlists"
working_directory path to PPP working directory, a directory accessible by both PPP and Plex "/mnt/PPP"
working_directory_plex path to PPP working directory as seen by Plex. Change it if Plex is running in a container and cannot see working_directory "/data/mnt/PPP"
section_id the library section which contains all your music (only one section is supported by the Plex API) "11"
local_prepend path to be ignored in local playlists "Z:\\Media\\Music\\"
plex_prepend path to be ignored in Plex playlists "/mnt/Media/Music"
local_convert only if local playlists are in a different directory format to your PPP machine "w2u"
plex_convert only if you Plex playlists are in a different directory format to your PPP machine False
--- EXAMPLE LOCAL_PLAYLIST ---
Z:\Media\Music\Andrew Huang\Love Is Real\Love Is Real.mp3
Z:\Media\Music\Ben Howard\Noonday Dream\A Boat To An Island On The Wall.mp3
Z:\Media\Music\Bibio\PHANTOM BRICKWORKS\PHANTOM BRICKWORKS.mp3

--- EXAMPLE PLEX_PLAYLIST ---
/mnt/media/Music/Andrew Huang/Love Is Real/Love Is Real.mp3
/mnt/media/Music/Ben Howard/Noonday Dream/A Boat To An Island On The Wall.mp3
/mnt/media/Music/Bibio/PHANTOM BRICKWORKS/PHANTOM BRICKWORKS.mp3

In the examples above, local_prepend is "Z:\\Media\\Music\\" and plex_prepend is "/mnt/Media/Music"

In this example, PPP is running on a machine which uses UNIX paths (/ not \), and so local_convert is "w2u" - which means Windows paths are converted to UNIX paths.

If running PPP on Windows and your playlist paths are UNIX, use "u2w", and if both paths are the same format use false.

Why are there so many backslashes? You need to double any backslash, because normally it's a special 'escape character' which would break the code. You need to 'escape' the 'escape character' (https://stackoverflow.com/questions/19095796/how-to-print-backslash-with-python)

ppp's People

Contributors

baruch95 avatar brittonbowman avatar dan0v avatar gotson avatar jellewestenberger avatar xdgfx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ppp's Issues

Playlists not pushing to Plex

Hi, this seems like a great tool and everything seems to be working on my local side and the GET from Plex, but I can't seem to push anything to Plex. This is a new library, running Plex as a container on Raspbian/OMV. The script runs end to end without errors, the working folders are filled with all the playlists for Local, Temp and Plex whilst the script is running. The token works and the test playlist I have on Plex is grabbed and merged (albeit with duplicates each appending each time) to a local playlist successfully. I'm running PPP from a Windows machine (Python 3.9) on as admin and there are 'everyone rwx' rights to the working folder, which is volume bound on Plex container. In the Plex logs, there seems to be only a GET on Plex and not much else. Sorry to be posting here, I've looked through all the open and closed issues and just wondering if anyone encountered this or has a way for me to trouble shoot? Seems like a great Google Play Music substitute that I can use in conjunction with MusicBee.

Playlists not being sent to Plex, everything else seems to work

Hi, love the script. I consider this an essencial part of anyone using Plexamp. A shame the ppl at Pleax don't agree.

Anyway I have plex running on a NAS and I ran the script locally. Got the following log:


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                     _____  _____  _____                         #
#                    |  __ \|  __ \|  __ \                        #
#                    | |__) | |__) | |__) |                       #
#                    |  ___/|  ___/|  ___/                        #
#                    | |    | |    | |                            #
#                    |_|    |_|    |_|  v3.0.6                    #
#                                                                 #
#              --- PPP Copyright (C) 2020 XDGFX ---               #
#                                                                 #
#  This program comes with ABSOLUTELY NO WARRANTY.                #
#  This is free software, and you are welcome to redistribute it  #
#  under certain conditions                                       #
#                                                                 #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


Running PPP at 2022-11-30-21-49-11

Attempting to load existing variables...

Variables loaded successfully!

------

I'll ignore  from local playlists and \volume2\music from Plex playlists     

Plex playlists will be converted from Unix to Windows directories
Local playlist paths will not be converted
SSL certificates will be validated

------

Attempting to make .tmp folders
Successfully created .tmp folders

------

INFO: Number of backups (11) exceeds backup retention (10)
Deleted oldest backup

------

Backing up local playlists...

Backed up local playlists to local_backups/2022-11-30-21-49-11
INFO: Your backups are currently taking up 10.24MB of space

------

Requesting playlists from Plex...
URL: SECRET/playlists/?X-Plex-Token=***********
Request was successful.

------

Found 3 playlists.

------

Requesting playlist data from Plex...
URL: SECRET/playlists/115161/items?X-Plex-Token=***********
Request was successful.

------

Found playlist: 5Stars
Found 0 songs.
Saving Plex playlist: 5Stars
Save successful!

------

Requesting playlist data from Plex...
URL: SECRET/playlists/115138/items?X-Plex-Token=***********
Request was successful.

------

Found playlist: Ffxiv
Found 474 songs.
Saving Plex playlist: Ffxiv
Save successful!

------

Requesting playlist data from Plex...
URL: SECRET/playlists/115139/items?X-Plex-Token=***********
Request was successful.

------

Found playlist: Love
Found 21 songs.
Saving Plex playlist: Love
Save successful!

------

Copying local playlist: /volume2/music/MusicBee/Exported Playlists/Most Played.m3u
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/3Stars.m3u
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/5Stars.m3u
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/4Stars.m3u
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/Car.m3u   
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/Gym.m3u   
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/Hate.m3u  
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/Love.m3u  
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/Mix it up.m3u
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/Ffxiv.m3u 
Copying local playlist: /volume2/music/MusicBee/Exported Playlists/Recently Added.m3u

------

Found new local playlist: Most Played.m3u

------

Found new local playlist: 3Stars.m3u

------

Found new local playlist: 4Stars.m3u

------

Found new local playlist: Car.m3u

------

Found new local playlist: Gym.m3u

------

Found new local playlist: Hate.m3u

------

Found new local playlist: Mix it up.m3u

------

Found new local playlist: Recently Added.m3u

------

Merging: 5Stars.m3u
Merging: Love.m3u
Merging: Ffxiv.m3u

------

Sending updated playlist to Plex: 5Stars.m3u
Sending updated playlist to Plex: Ffxiv.m3u
Sending updated playlist to Plex: Love.m3u
Sending updated playlist to Plex: Most Played.m3u
Sending updated playlist to Plex: 3Stars.m3u
Sending updated playlist to Plex: 4Stars.m3u
Sending updated playlist to Plex: Car.m3u
Sending updated playlist to Plex: Gym.m3u
Sending updated playlist to Plex: Hate.m3u
Sending updated playlist to Plex: Mix it up.m3u
Sending updated playlist to Plex: Recently Added.m3u

------

Copying updated playlist to local playlists: Most Played.m3u
Copying updated playlist to local playlists: 3Stars.m3u
Copying updated playlist to local playlists: 5Stars.m3u
Copying updated playlist to local playlists: 4Stars.m3u
Copying updated playlist to local playlists: Car.m3u
Copying updated playlist to local playlists: Gym.m3u
Copying updated playlist to local playlists: Hate.m3u
Copying updated playlist to local playlists: Love.m3u
Copying updated playlist to local playlists: Mix it up.m3u
Copying updated playlist to local playlists: Ffxiv.m3u
Copying updated playlist to local playlists: Recently Added.m3u

------

Complete!

This is my variables.json

{
  "server_url": "SECRET",
  "check_ssl": "True",
  "plex_token": "SECRET_LOL",
  "local_playlists": "/volume2/music/MusicBee/Exported Playlists/",
  "working_directory": "/volume2/Storage2/PPP/workingdirectory",
  "working_directory_plex":"volume2/Storage2/PPP/workingdirectory",
  "section_id": "7",
  "plex_prepend": "/volume2/music",
  "local_convert": false,
  "plex_convert": "u2w"
}

I mean it looks like it's working but it's never updating plex and I'd love to know why

Traceback (most recent call last): error.

Description

Getting this error when I try to run the script.

image

I have been able to follow everything through. such as running pip install requests, and editing the environment variables. but has made no difference.

pip version

22.0.3

Python version

3

OS

windows 11

How to Reproduce

install python 3 from windows store.
download the latest zip from releases and extract.
shift and right-click to open PowerShell here.
type cmd
type pip install requests

Click Start, search for "environment variables". Click "edit environment variables".
If the top box (user variables) has one named "Path", click on it, click "Edit". A new window pops up. Click "New" and paste in "'C:\Users\USERNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts". or whatever location the warning says.

In command prompt type pip install --upgrade pip just to be sure.

type python3 PPP.py and follow through as normal until the end, when you get this error.

Output

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                     _____  _____  _____                         #
#                    |  __ \|  __ \|  __ \                        #
#                    | |__) | |__) | |__) |                       #
#                    |  ___/|  ___/|  ___/                        #
#                    | |    | |    | |                            #
#                    |_|    |_|    |_|  v3.0.6                    #
#                                                                 #
#              --- PPP Copyright (C) 2020 XDGFX ---               #
#                                                                 #
#  This program comes with ABSOLUTELY NO WARRANTY.                #
#  This is free software, and you are welcome to redistribute it  #
#  under certain conditions                                       #
#                                                                 #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


Running PPP at 2022-02-10-15-40-15

Attempting to load existing variables...

INFO: Couldn't find existing variables... proceeding with initial setup

It looks like you haven't run this script before!
The setup process is now starting...

If you believe this is an error, please check variables.json is present, and accessible by PPP.

------

It looks like your PPP machine uses Windows paths

------

First things first... what is your Plex server URL, as seen by PPP? It must include port, in the form '192.198.1.10:32400'
Please enter your server URL: LOCALIP:32400

------

Next we need your Plex Token. You can find this by following these instructions: https://bit.ly/2p7RtOu
Please enter your Plex Token: TOKEN HERE

------

Would you like to check SSL certificates? If unsure press enter for default
Validate SSL certificate? - enabled by default (y / n):

------

Requesting playlists from Plex...
URL: http://LOCALIP:32400/playlists/?X-Plex-Token=***********
Request was successful.

------

Found 13 playlists.

------


------

Fetching sample playlist(s) to determine prepend...
Requesting playlist data from Plex...
URL: http://LOCALIP:32400/playlists/26398/items?X-Plex-Token=***********
Request was successful.

------

Found playlist: Anjunabeats/Anjunadeep.
Found 4 songs.
It looks like your Plex machine uses UNIX paths
Requesting playlist data from Plex...
URL: http://LOCALIP:32400/playlists/26396/items?X-Plex-Token=***********
Request was successful.

------

Found playlist: Black Lacquer: A Remix Project
Found 24 songs.
Plex playlists are not in PPP directory format!
Attempting to convert Plex directories to PPP machine format
Calculated Plex Prepend: \media\audio\music

------

Now we need the location of your local playlists, as seen by PPP
There is no need to escape spaces or special characters.
Please enter your local playlists directory: C:\Users\USERNAME\Downloads\Newfolder

------

Traceback (most recent call last):
  File "C:\Users\USERNAME\Downloads\PPP-3.0.6\PPP.py", line 485, in <module>
    v = setupVariables()
  File "C:\Users\USERNAME\Downloads\PPP-3.0.6\PPP.py", line 241, in setupVariables
    os.path.join(root, file), 'r', encoding='utf8').read().splitlines()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 668: invalid continuation byte

Half of the playlists tracks aren't getting pushed to Plex

So I just created a new playlist with around 100 songs on it and when I ran the program, only 46 of the songs on the m3u showed up on Plex. I checked and it seems that the songs that aren't getting pushed are those which paths get dangerously close to the character limit.

So those with around 200 characters on the path won't get pushed no matter what I try.

Is there a way to address this without modifying my directories?

doesn't work with / in playlist name

Sorry, I haven't posted issues to github before. I hope this is the right way to do it.

As you can see, the playlist name has a slash in it, and that causes an error. The error didn't occur after I changed the playlist name to use a dash instead of a slash. Cheers.

Requesting playlist data from Plex...
URL: http://192.168.0.148:32400/playlists/102329/items?X-Plex-Token=***********
Found playlist: James / Tim Booth
Found 290 songs.
Saving Plex playlist: James / Tim Booth
Traceback (most recent call last):
File "./PPP.py", line 555, in
'w+', encoding='utf8')
FileNotFoundError: [Errno 2] No such file or directory: '.tmp/plex/James / Tim Booth.m3u'

What is PPP install directory?

I don't understand what is the install_directory and why would Plex need to see it?

I am trying to run PPP on my macbook, and Plex is running on another server, within a docker container.

What should i put for this install_directory? Is this the same directory containing PPP.py and the rest of the zip file i got from the GH releases?

I tried to put an arbitrary empty directory visible to my Plex container, and using the path as seen from the container, but the playlist does not get updated despite the logs saying so.

Smart playlists

I've managed to extract playlists from Plex 3.0.1. Support for smart playlists as 1-way sync / export would be nice.

Nevertheless there is a workaround to use PPP with smart playlists right now: clear the current playlist. Add the smart playlist to the current playlist so that only those songs are currently played. Save the current playlist to a regular playlist.

FYI: I'd use it to extract star rated songs as playlists and re-import them in WMP. WMP can batch rate songs from a playlist. Those song ratings are saved by WMP in the songs itself, improving backup safety of that information a lot. I spent a lot of time with rating my music actually.

Crash if playlist has no item

Trying to run the setup for the first time, PPP crashes because one playlist has no item.

Fetching sample playlist to determine prepend...
Requesting playlist data from Plex...
URL: http://leon:32400/playlists/9216/items?X-Plex-Token=***********
Found playlist: Electro - Demo
Found 0 songs.
Traceback (most recent call last):
  File "PPP.py", line 491, in <module>
    v = setupVariables()
  File "PPP.py", line 211, in setupVariables
    plex_unix = playlist[0].startswith("/")
IndexError: list index out of range

ValueError: Can't mix absolute and relative paths

Getting an error about paths on initial run. My playlist (despite what it says) does use UNIX paths, not Windows.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

_____ _____ _____

| __ | __ | __ \

| |) | |) | |__) |

| ___/| ___/| ___/

| | | | | |

|| || |_| v3.0.6

--- PPP Copyright (C) 2020 XDGFX ---

This program comes with ABSOLUTELY NO WARRANTY.

This is free software, and you are welcome to redistribute it

under certain conditions

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Running PPP at 2023-01-18-14-10-12

Attempting to load existing variables...

INFO: Couldn't find existing variables... proceeding with initial setup

It looks like you haven't run this script before!
The setup process is now starting...

If you believe this is an error, please check variables.json is present, and accessible by PPP.


It looks like your PPP machine uses UNIX paths


First things first... what is your Plex server URL, as seen by PPP? It must include port, in the form '192.198.1.10:32400'
Please enter your server URL: 127.0.0.1:32400


Next we need your Plex Token. You can find this by following these instructions: https://bit.ly/2p7RtOu
Please enter your Plex Token: (redacted)


Would you like to check SSL certificates? If unsure press enter for default
Validate SSL certificate? - enabled by default (y / n): n


Requesting playlists from Plex...
URL: http://127.0.0.1:32400/playlists/?X-Plex-Token=***********
Request was successful.


Found 2 playlists.



Fetching sample playlist(s) to determine prepend...
Requesting playlist data from Plex...
URL: http://127.0.0.1:32400/playlists/25168/items?X-Plex-Token=***********
Request was successful.


Found playlist: A Fish Has No Word For Water
Found 25 songs.
It looks like your Plex machine uses UNIX paths
Requesting playlist data from Plex...
URL: http://127.0.0.1:32400/playlists/25169/items?X-Plex-Token=***********
Request was successful.


Found playlist: Main
Found 391 songs.
Calculated Plex Prepend: /mnt/Media/Music


Now we need the location of your local playlists, as seen by PPP
There is no need to escape spaces or special characters.
Please enter your local playlists directory: /mnt/Media/Playlists


It looks like your local playlists use Windows paths
Local playlists are not in PPP directory format!
Attempting to convert local directories to PPP machine format
Traceback (most recent call last):
File "/mnt/Media/Scripts/PPP/./PPP.py", line 485, in
v = setupVariables()
File "/mnt/Media/Scripts/PPP/./PPP.py", line 266, in setupVariables
local_prepend = os.path.commonpath(playlist)
File "/usr/lib/python3.9/posixpath.py", line 510, in commonpath
raise ValueError("Can't mix absolute and relative paths") from None
ValueError: Can't mix absolute and relative paths
addie@Liz:/mnt/Media/Scripts/PPP$

doesnt seam to work in windows

not sure if i have set this up or what but it doesn't seam to be working. I trying this out in windows 10. i have tried the line 229 fix but that doesn't work.

Can't upload playlists that span multiple sectionIDs

I have two libraries, "Singles" and "Albums", and a playlist that spans both.

The script only specifies a single sectionId as a query parameter, and an upload appears to replace an existing playlist (vs. append), so it looks like I can do only one or the other.

I tried the following to pass two sectionIDs to the API to no avail:

  • sectionID=1&sectionID=2 (just takes the first one)
  • sectionID=1,2 (500)
  • sectionID[]=1&sectionID[]=2 (bad request)

Any ideas? Thanks for putting this together!

importing seemingly random files

It seems that whenever the script imports playlists that have entries with unmatched files, it attempts to replace that entry with something else. I'm not sure what logic it is using, but it is not at all accurate. I'm guessing this is happening on Plex's end, once you feed the playlist to it. Does their API provide an error code or some other feedback that the inputted playlist entry is not found?

Thanks!

Backup not working if PPP.py and *.m3u files in same folder

Using a network shared folder with the same relative path (e.g. /media/MusicShare/Playlist/) for both local and plex machines. With both the PPP.py and *.m3u files located in this same networked folder the backup will run very deep with many recursive folders of the same content and end with error 'shutil.SameFileError: '/media/MusicShare/Playlist/tmp/local/test.m3u' and 'tmp/local/test.m3u' are the same file'

Moving the PPP.py to a different folder on the same network drive (e.g. media/MusicShare/PPP/) solved the recursive backup problem.

Can't access local playlists

Hi I'm trying this for the first time.
Running on a W10 machine.
When trying to do initial setup I'm stuck at the local playlist directories as I get this error

Traceback (most recent call last):
  File "PPP.py", line 498, in <module>
    v = setupVariables()
  File "PPP.py", line 257, in setupVariables
    playlist = io.open(
  File "C:\Python38-32\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 21: invalid start byte

EDIT: Solved by doing what was referenced in #8
Now I get another error. Every single playlist got duplicated in Plex.

[guide] convert to *.wpl playlist to sync with Windows Media Player

There're lots of playlist formats and file encodings and even more software to read them for playback. Resulting in issues like #8 and #15. After doing some research and tests, I'll describe here a very simple method to solve at least one of such scenarios: convert the m3u output from PPP to .wpl, that Windows Media Player can finally read (my previous approach to just convert to ANSI (#8) didn't work fully). I've tested 800 songs containing a lot of arbitrary characters in their file path. And oll of them worked: ä ' [ & - ! ) _ and so on. While it's a semi-automated description, the steps could be implemented in PPP by someone in probably no time.

3 steps are required, basically converting the m3u from PPP to an xml file. I do this with Notepad++ and the search and replace feature:

  1. replace 5 characters forbidden in xml
  2. enclose each line in a xml tag (add a prefix to each line, add a suffix to each line)
  3. add a static header and footer to the file

Steps in detail
1)
Replace the following 5 characters with these strings (like also described here):

< to &lt;
> to &gt;
& to &amp;
" to &qout;
' to &apos;

2)
Add to each line the prefix (notepad++ enable regex and search for ^ to get the begin of a line)

<media src="

Add to each line the suffix (notepad++ enable regex and search for $ to get the end of a line)

"/>

3)
Add to the beginning of the file

<?wpl version="1.0"?>
<smil>
    <body>
        <seq>

Add to the end of the file

	</seq>
    </body>
</smil>

Save as *.wpl.
done.

This should also work the opposite way around.

Would be nice to have someone implement this :)

Playlists not pushed to Plex

Seems like I'm experiencing a similar issue to #11 using version 3.5. This is also the first time I've used it, so there may be a setup issue.

PPP seems to be reading both sets of playlists ok, and it successfully pushes anything new to my local playlists, but nothing gets updated in Plex. My logs on both sides look basically the same as what dan0v posted.

Excerpts from PPP log:

Requesting playlists from Plex...
URL: http://10.0.0.111:32400/playlists/?X-Plex-Token=***********
Requesting of playlists was successful.
Found 2 playlists.

------

Requesting playlist data from Plex...
URL: http://10.0.0.111:32400/playlists/29251/items?X-Plex-Token=***********
Found playlist: dummy
Found 2 songs.
Saving Plex playlist: dummy
Save successful!

and:
Sending updated playlist to Plex: Running.m3u

But none of my local playlists (using "Running.m3u" above is just an example--I have a couple dozen) are pushed to Plex. The dummy playlist I created in Plex is pushed to local, however.

Here's what Plex sees:

May 18, 2020 23:04:46.414 [15552] DEBUG - Auth: authenticated user 1 as [username]
May 18, 2020 23:04:46.415 [23232] DEBUG - Request: [10.0.0.111:56467 (Subnet)] GET /playlists/ (4 live) GZIP Signed-in Token (cjhesse)
May 18, 2020 23:04:46.417 [8576] DEBUG - Completed: [10.0.0.111:56467] 200 GET /playlists/ (4 live) GZIP 2ms 397 bytes (pipelined: 1)

and:

May 18, 2020 23:04:47.319 [15552] DEBUG - Auth: authenticated user 1 as [username]
May 18, 2020 23:04:47.319 [23232] DEBUG - Request: [10.0.0.111:56505 (Subnet)] POST /playlists/upload?sectionID=4&path=..%5C.tmp%5Cplex%5CzArtistsL-M.m3u (4 live) GZIP Signed-in Token ([username])
May 18, 2020 23:04:47.320 [8576] DEBUG - Completed: [10.0.0.111:56505] 200 POST /playlists/upload?sectionID=4&path=..%5C.tmp%5Cplex%5CRunning.m3u (4 live) GZIP 0ms 195 bytes (pipelined: 1)

Closing out the Plex browser session, restarting the server, and rebooting the computer don't fix the issue, nor does waiting a day to see if things show up. A few other points that may or may not be notable:

  • Soundiiz can add uploaded (.m3u) playlists to Plex, but does an awful job of matching songs. I tried one playlist of 80 songs and it only successfully added one of those to Plex.
  • I have my media folders set up as a network share so everything can access them using the same paths on a mapped drive--therefore, the local playlists all have the songs mapped under M:\MusicBee, and this is what PPP ignores from local playlists.
  • Plex is set up using the actual drive's path (D:\OneDrive\Music\MusicBee) and that's what PPP ignores from Plex playlist paths.
  • Most (not all) of my playlists are organized into subfolders, but PPP seems to have no problem finding them.

Thanks for any help you can give, and for writing this program!

Ability to keep a local copy intact?

When I run this on my Playlist directory and it changes the paths of the files, adding the preamp the files become unable to be opened with a local player.
I can easily just copy it on notepad and remove the preamp path and it becomes usable again but since this is really cool for keeping playlist synced it would be great if it gave the option of keeping a clean copy of the playlisy for local usage.

"This file does not have an app associated with it for performing this action. Please install an app or, if one is already installed, create an association in the Default Apps Settings page."

Hello,

I am trying to install PPP. I already have Python 3 installed, and I downloaded the PPP zip and extracted it with 7zip.

In the command window, I navigate to the extracted folder and try running: PPP.py -setup

I get the following error:

"This file does not have an app associated with it for performing this action. Please install an app or, if one is already installed, create an association in the Default Apps Settings page."

Playlists are not created

The script seems to run successfully but the playlists are not created.
System I'm running this from is using PopOS and the plex server is running on a Raspberry Pi 4.

Here's the full output - everything looks like it's successful, but the playlists just don't appear.

EDIT: Upon further inspection it looks like the windows paths are being used by default here - my files have backslashes for the directories after running the script, but that's not the case when they're exported- even when that flag is set to false.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#                     _____  _____  _____                         #
#                    |  __ \|  __ \|  __ \                        #
#                    | |__) | |__) | |__) |                       #
#                    |  ___/|  ___/|  ___/                        #
#                    | |    | |    | |                            #
#                    |_|    |_|    |_|  v3.0.6                    #
#                                                                 #
#              --- PPP Copyright (C) 2020 XDGFX ---               #
#                                                                 #
#  This program comes with ABSOLUTELY NO WARRANTY.                #
#  This is free software, and you are welcome to redistribute it  #
#  under certain conditions                                       #
#                                                                 #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 


Running PPP at 2020-09-02-15-15-08

Attempting to load existing variables...

Variables loaded successfully!

------

I'll ignore ..\..\Music from local playlists and /home/annie/PlexMedia/Music/* from Plex playlists

Plex playlist paths will not be converted
Local playlists will be converted from Windows to Unix directories
SSL certificates will be validated

------

Attempting to make .tmp folders
Successfully created .tmp folders

------

Backing up local playlists...

Backed up local playlists to local_backups/2020-09-02-15-15-08
INFO: Your backups are currently taking up 12561.36MB of space

------

Requesting playlists from Plex...
URL: http://192.168.1.10:32400/playlists/?X-Plex-Token=***********
Request was successful.

------

Found 1 playlists.

------

Requesting playlist data from Plex...
URL: http://192.168.1.10:32400/playlists/3569/items?X-Plex-Token=***********
Request was successful.

------

Found playlist: Dummy
Found 123 songs.
Saving Plex playlist: Dummy
Save successful!

------

Copying local playlist: /home/annie/Drive/Playlists/5 Video Game Filtered.m3u
Copying local playlist: /home/annie/Drive/Playlists/4 Video Game Filtered.m3u
Copying local playlist: /home/annie/Drive/Playlists/5 Video Game.m3u
Copying local playlist: /home/annie/Drive/Playlists/4 Video Game.m3u
Copying local playlist: /home/annie/Drive/Playlists/4 Indie.m3u
Copying local playlist: /home/annie/Drive/Playlists/5 V.m3u
Copying local playlist: /home/annie/Drive/Playlists/4 V.m3u
Copying local playlist: /home/annie/Drive/Playlists/5.m3u
Copying local playlist: /home/annie/Drive/Playlists/4.m3u
Copying local playlist: /home/annie/Drive/Playlists/Dummy.m3u

------

Found new local playlist: 5 Video Game Filtered.m3u

------

Found new local playlist: 4 Video Game Filtered.m3u

------

Found new local playlist: 5 Video Game.m3u

------

Found new local playlist: 4 Video Game.m3u

------

Found new local playlist: 4 Indie.m3u

------

Found new local playlist: 5 V.m3u

------

Found new local playlist: 4 V.m3u

------

Found new local playlist: 5.m3u

------

Found new local playlist: 4.m3u

------

Merging: Dummy.m3u

------

Sending updated playlist to Plex: Dummy.m3u
Sending updated playlist to Plex: 5 Video Game Filtered.m3u
Sending updated playlist to Plex: 4 Video Game Filtered.m3u
Sending updated playlist to Plex: 5 Video Game.m3u
Sending updated playlist to Plex: 4 Video Game.m3u
Sending updated playlist to Plex: 4 Indie.m3u
Sending updated playlist to Plex: 5 V.m3u
Sending updated playlist to Plex: 4 V.m3u
Sending updated playlist to Plex: 5.m3u
Sending updated playlist to Plex: 4.m3u

------

Copying updated playlist to local playlists: 5 Video Game Filtered.m3u
Copying updated playlist to local playlists: 4 Video Game Filtered.m3u
Copying updated playlist to local playlists: 5 Video Game.m3u
Copying updated playlist to local playlists: 4 Video Game.m3u
Copying updated playlist to local playlists: 4 Indie.m3u
Copying updated playlist to local playlists: 5 V.m3u
Copying updated playlist to local playlists: 4 V.m3u
Copying updated playlist to local playlists: 5.m3u
Copying updated playlist to local playlists: 4.m3u
Copying updated playlist to local playlists: Dummy.m3u

------

Complete!

Script runs fine with no errors, but no playlists are showing in plex

Hello, i've been trying to figure out why this doesn't work.

I'm running plex on a docker container and the script from a ubuntu VM. i make sure that the directories are visible from both plex container and the vm. i edited the variables and the script runs fine with no errors. But no playlists are being uploaded to the server.

What am i doing wrong?

Exclude .DS_Store from local_backups cleanup

The app crashes when it encounters a file that isn't a directory inside the local_backups folder.

This is fine usually but on macOS the system occasionally inserts .DS_Store files.

You need to filter to just directories for the cleanup or specifically ignore .DS_Store files.

Traceback (most recent call last):
  File "PPP.py", line 542, in <module>
    backupLocal()
  File "PPP.py", line 380, in backupLocal
    'local_backups', backups[oldest_backup]))
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 494, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 413, in _rmtree_safe_fd
    onerror(os.scandir, path, sys.exc_info())
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 409, in _rmtree_safe_fd
    with os.scandir(topfd) as scandir_it:
NotADirectoryError: [Errno 20] Not a directory: 'local_backups/.DS_Store'

P.S. I love this tool, thanks for making it! If my Python was better I would submit a pull request.

Import playlists for different users

Hi thanks for the script. It has helped me a lot.
The playlists load for the main user of the server, is it possible to also import the playlists for another user?

Path with % gets ignored.

I have some albums with 100% on the name so naturally the folder includes it in its path.
When adding that album, either via plex or the local player, it disappears after running PPP
The playlist gets all its tracks minus that album after the sync

Getting "Return code: 500 Reason: Internal Server Error"

I am trying to set up PPP. I'm using a Windows machine.

Everything seems to be working during the setup phase. It finds my local playlists fine. But when it comes time to actually run PPP, I get the following:

Sending updated playlist to Plex: highlife.m3u ERROR: Return code: 500 Reason: Internal Server Error

Issues on First Launch

Using Python 3.9 for Windows 10 (64-bit)
Using PPP.py v3.0.6

On first run, when I expect SETUP to run, launching PPP.py just crashes the Python window. Any suggestions?
I can open the Python terminal window on its own just fine. Do I need to edit 'example-variables.json' before SETUP can run?

Doesn't support *.m3u8 files

Foobar forces user to save a playlist in m3u8 format when it detects problematic characters.
Unfortunately, your script doesn't work with m3u8 playlists.
If you force foobar to save problematic playlist in m3u format, your script will throw decoding errors.

My workaround was:
Resaving the foobar-created m3u file (that your script couldn't decode) in windows-notepad while forcing utf8.

Thank you for sharing this script!

adding file to end of playlist

When importing a playlist, PPP adds an extra song at the end. For some reason, it adds "Namu Amida Buddha" every time. The original playlist, named "onesong", only contained the entry for "Ship of Fools" (same thing happens with other songs, and with longer playlists).

Screenshot_2020-01-26 Robert Anton Wilson - Namu Amida Buddha

Note the "..." for the playlist song number.

Playlist does not show in Plex

Hi,

first of all: Thanks for writing this. I would love to use it to sync my playlists with Musicbee.

I've got an issue with running the script on my QNAP. After running it the Playlist from Musicbee does not show up in Plex.

This is a log of the run:

[/share/Music/PPP] # /share/CE_CACHEDEV1_DATA/.qpkg/Python3/src/bin/python3 PPP.py

PPP Copyright (C) 2019 XDGFX
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions

I'll ignore "\\192.168.2.150\Music" from local playlists and "/share/CE_CACHEDEV1_DATA/Music" from Plex playlists

Running PPP at 2019-11-18 13:54:29

Backing up local playlists...

Backed up local playlists to local_backups/2/

Getting playlists from http://192.168.2.150:32400/playlists/?X-Plex-Token=73hqvjcB-qso9zbw95vw

Accessing http://192.168.2.150:32400/playlists/23010/items?X-Plex-Token=73hqvjcB-qso9zbw95vw
Saving Plex playlist: Watch with Annika

Copying local playlist: /share/CE_CACHEDEV1_DATA/Music/MusicSync/Playlists/Test.m3u
Found new Plex playlist: Watch with Annika.m3u
Found new local playlist: Test.m3u
Sending updated playlist to Plex: Watch with Annika.m3u

Sending updated playlist to Plex: Test.m3u

Copying updated playlist to local playlists: Test.m3u
Complete!

[/share/Music/PPP] #

My structure is like this:
My Music files are on a NAS Share \192.168.2.150\Music Which is the prepend Musicbee uses when exporting a m3u playlist:

\\192.168.2.150\Music\Kinder\Music\Das Dschungelbuch (Original Soundtrack)\05 Probiers mal mit Gemütlichkeit.m4a
\\192.168.2.150\Music\Kinder\Music\Giraffenaffen\Giraffenaffen 1\03 Hätt' ich Dich heut' erwartet (fe.mp3
\\192.168.2.150\Music\Kinder\Music\Giraffenaffen\Giraffenaffen 1\11 Die Affen rasen durch den Wald.mp3

Seen from the NAS/Plex

  • the Music is in /share/CE_CACHEDEV1_DATA/Music
  • the Playlists are in /share/CE_CACHEDEV1_DATA/Music/MusicSync/Playlists
  • PPP is in /share/CE_CACHEDEV1_DATA/Music/PPP

But after the run the test.m3u looksgood again (so the replacement worked) but I don't see any new playlists in Plex.

  • 2 thoughts: Should the playlist even show up if the files names are wrong?
  • The files all have a "" from windows in the m3u which does ont corrospond to the linux "/" - is that an issue?

Thanks again

Issue entering Server URL

image
I am entering : as per the help text that displays for the PMS URL. But PPP doesn't like it...
What have I got wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.