ukdtom / WebTools.bundle

WebTools is a collection of tools for Plex Media Server. Like the Unsupported AppStore (UAS)
https://forums.plex.tv/discussion/288191
Mozilla Public License 2.0
1.3k stars 170 forks source link

Playlist Import Length Limited to 30 titles #525

Closed Psychocrysma closed 5 years ago

Psychocrysma commented 5 years ago

Environment

Error shown

Steps to reproduce

  1. Build a playlist of 31 songs or more.
  2. Download it.
  3. Delete it from Plex.
  4. Import it.

Expected behaviour

  1. The whole playlist, no matter the size, will be imported.

Actual behaviour

  1. Upon importation, the actual playlist on plex will contain only 30 songs.

Additional Info

I have produced this bug not manually but while trying to cheat the system. I made a quick C# converter to convert my winamp playlists into a usable file. And they work very well, but they stop at 30. This is why I checked if this issue was produced manually, and it is.

PMSLogs_20181116-082935.zip

Checklist

ukdtom commented 5 years ago

I see errors in the log, like:

2018-11-16 07:29:23,601 (359c) : CRITICAL (core:574) - Exception happened in Playlist import was: 'utf8' codec can't decode byte 0x8c in position 0: invalid start byte (most recent call last): File "D:\Users\Gabriel\AppData\Local\Plex Media Server\Plug-ins\WebTools.bundle\Contents\Code\playlistsV3.py", line 367, in IMPORT success.append(unicode(items[item]['title'])) UnicodeDecodeError: 'utf8' codec can't decode byte 0x8c in position 0: invalid start byte

Got a title that starts with ƌperhaps?

Also: Ƒ seen in: 2018-11-16 08:08:57,871 (359c) : CRITICAL (core:574) - Exception happened in Playlist import was: 'utf8' codec can't decode byte 0x91 in position 0: invalid start byte (most recent call last): File "D:\Users\Gabriel\AppData\Local\Plex Media Server\Plug-ins\WebTools.bundle\Contents\Code\playlistsV3.py", line 367, in IMPORT success.append(unicode(items[item]['title'])) UnicodeDecodeError: 'utf8' codec can't decode byte 0x91 in position 0: invalid start byte

ukdtom commented 5 years ago

Also, you should switch locale of your server to utf-8

******* Started WebTools V3.0.0 on Windows at 2018-11-16 07:25 with locale set to ('en_GB', 'cp932')

ukdtom commented 5 years ago

Scratch above, since you are running Windows :(

Psychocrysma commented 5 years ago

Ah yes sorry this was during testing. Many of my song titles are in Japanese, so my playlists go through encoding JIS. And then I convert them to UTF 8 manually.

Psychocrysma commented 5 years ago

In these examples, I simply forgot to manually convert them. My bad.

ukdtom commented 5 years ago

Can you provide a fresh set of logs, in utf-8?

Psychocrysma commented 5 years ago

That said, the Japanese title were being imported with no issue. It really is only the 30 length limit that was problematic for me. After all, my playlists have around 700 titles each.

ukdtom commented 5 years ago

I still would like a fresh set of logs ;)

Psychocrysma commented 5 years ago

Sure, let me run my virtual machine again...

Psychocrysma commented 5 years ago

As a side note, what do the ID and ListID stand for in the playlists?

ukdtom commented 5 years ago

ID: Key of media within PMS ListID: Key of Media within the Playlist itself

Psychocrysma commented 5 years ago

Is this something that is set by Plex already or you can set it yourself? Also, here are the clean logs. The first shot was done with a manual playlist. The second was done with the playlist stored within the ZIP. Logs and Playlist.zip

The reason I ask is that my IDs and ListIDs from my custom edit are randomly generated from each previous number within a difference of 20. That may be involved in the breaking. And yet, it still adds some. And it's always the same ones.

ukdtom commented 5 years ago

See for yourself, by browsing to:

http://IPOFPMS:32400/playlists/KEYOFPLAYLIST/items?X-Plex-Token=YOURTOKEN

So if on the server, try: http://127.0.0.1:32400/playlists/3823/items?X-Plex-Token=YOURTOKEN

You can get your TOKEN from the TechModule of WebTools

Psychocrysma commented 5 years ago

That gives me an Error 404.

ukdtom commented 5 years ago

Means not found, so you deleted the playlist in the mean time ;)

Try: http://127.0.0.1:32400/playlists?X-Plex-Token=YOURTOKEN

to get a list of playlists, and then use the ratingkey value as KEYOFPLAYLIST

Psychocrysma commented 5 years ago

I guess that value is set then but the first track's there and the ID the playlist had set was completely different so I really am not sure if that's the issue.

Psychocrysma commented 5 years ago

Alright I want to update regarding this: I am pretty sure my issue is caused by the fact that my rating keys are broken. I have done some more testing with valid rating keys I've gotten through /library/metadata/ and it seems to be working better. However, at that point, I think it becomes less necessary to use WebTools at all. I am going to start working on an application in C# tomorrow that will run through http://192.168.0.xxx:32400/library/sections/1/all?X-Plex-Token= and basically pick off all its children and loop till it gets all the files necessary and basically make a valid playlist, then do a http://192.168.0.xxx:32400/playlists/upload?sectionID=1&path=F:\Music\Playlist.m3u8&X-Plex-Token= to directly upload it. And for the sake of efficiency, I might do a run through command line instead of using the urls.

Edit: Can you tell me where I could easily fetch ServerID (MachineID) programmatically? Should I go through \HKEY_CURRENT_USER\Software\Plex, Inc.\Plex Media Server in Regedit to fetch ProcessedMachineIdentifier (I don't like that the app would require additional administrator rights though) or is there another way?

ukdtom commented 5 years ago

http://IP_OF_PMS:32400/identity

Psychocrysma commented 5 years ago

The application is pretty much complete but I still seem to be unable to upload the playlist and the error I get from WebTools is "Error: playlistService.importPlaylist - Exception happened in Playlist import was: local variable 'ratingKey' referenced before assignment"

That said, all ratingKeys are taken from Plex. The only thing that I have assumed was not needed to be specific was ListID but perhaps I just don't understand what it is. Isn't that value representing like the index of a track within the playlist? Does it have to be specific or can it be one by one?

ukdtom commented 5 years ago

Sadly, dev work has been put on hold, due to plugins been discontinued by Plex

Ref: https://www.plex.tv/blog/subtitles-and-sunsets-big-improvements-little-housekeeping/

No new versions will be release, and this project has been put on hold

UAS will still be maintained for as long as it lasts