Kaiede / PlexPlaylistHost

Plugin to make PLEX music playlists available to UPnP/DLNA Clients.
MIT License
12 stars 3 forks source link

Request - Play All at the top #1

Open cjustinhall opened 4 years ago

cjustinhall commented 4 years ago

Love what you've done! I have this enabled at our place and the family loves it. Finally, finally, we have our plex playlists on our home automation tool.

Note I had to modify the code a bit to add the Plex token to all url requests but that was easy.

Q/Request - I'd love a "Play All" button at the top of the Playlist. For example, I navigate to Music Channels/Playlists/My Playlist Name/ <-- here I would love a Play All so that I don't have to add each track to the queue.

How could that get enabled? Ideas? Tips? Thanks.

Kaiede commented 4 years ago

Note I had to modify the code a bit to add the Plex token to all url requests but that was easy.

I’d happily entertain a pull request of this change. I haven’t needed it for my NAS-hosted Plex server, but I could believe it may be needed.

Q/Request - I'd love a "Play All" button at the top of the Playlist. For example, I navigate to Music Channels/Playlists/My Playlist Name/ <-- here I would love a Play All so that I don't have to add each track to the queue.

I’m curious what UPnP client you are using? Does it display a “Play All” button for other things like Albums hosted by the Plex server?

Servers can’t really add nodes that do anything to the client. The server is providing media information as a browsable tree.

I have played around with trying to use different node types so that clients will see the playlist more like an album, which should make it easier for some clients, but it might help to know what client you are using, since each one is a bit different about what it tolerates.

cjustinhall commented 4 years ago

Thanks for the speedy reply. I'll be honest that I'm far from a git guru so here are the changes made to support tokens...

DefaultPrefs.json

added

{ "id": "plextoken", "label": "Plex login token", "type": "text", "default": "my-token-here-that-I-found-from-viewing-xml-on-an-entity" }

In init.py

(under preferences) PREFS__PLEXTOKEN = 'plextoken'

(and the updated GetPlexUrl function)

def GetPlexUrl(suffix=None): plexUrl = 'http://%s:%s' %(Prefs[PREFSPLEXIP], Prefs[PREFSPLEXPORT]) if suffix is not None: plexUrl += suffix

plexUrl += '?X-Plex-Token='
plexUrl += Prefs[PREFS__PLEXTOKEN]

Log.Debug('Requesting Plex URL: %s' % (plexUrl))
return plexUrl
cjustinhall commented 4 years ago

WRT the tools I am using to play this playlist...

There are a couple layers. Let me break it down. The system is control4 so I have the c4 My DLNA driver on the controller. That driver lets me connect to Plex. On the c4 Navigators (mobile app or physical control devices) I get into the DLNA driver, then see Music Channels, then Playlists (driven from your plugin).

If I navigate to the music library, albums, and pick an album, the top item has extra controls showing - eg to shuffle play the album, or click play to start playing the album.

When I navigate to a playlist, the top item in the playlist doesn't have those controls. As I look around, it appears those controls are only at the Album level.

Which leads then to a more spotted question... is there a way the playlist can show, to the DLNA driver, that it is an "album" to gain those controls?

You mention that you've tried playing around with 'different node types so that clients will see the playlist more like an album' so actually feels like we are trying to achieve the same goal. Could you tell me where/how you change that node type and I can do some testing/changes and see if something else works?

Thanks!!!

Kaiede commented 4 years ago

here are the changes made to support tokens...

Just out of curiosity, do you use a value other than the defaults for the Plex host/port? Mostly trying to figure out why I don’t need it, but others might.

I’ve opened #2 to track work around plex tokens further.

If I navigate to the music library, albums, and pick an album, the top item has extra controls showing - eg to shuffle play the album, or click play to start playing the album.

So the extra controls are coming from the client detecting it as an album. StreamMagic does something similar where it can pop up certain extras by detecting the node type, while HEOS seems to mostly ignore the typing of node containing the tracks.

UPnP is fun. 😒

You mention that you've tried playing around with 'different node types so that clients will see the playlist more like an album' so actually feels like we are trying to achieve the same goal. Could you tell me where/how you change that node type and I can do some testing/changes and see if something else works?

If just changing the node type was enough, the change would have been committed to the repo by now. But CreatePlaylistObject drives what the Playlist node itself looks like, while CreateTrackObject drives the tracks inside the playlist. I suspect I need to provide more information in the playlist/track objects to keep clients happy when using an AlbumObject instead of DirectoryObject, but I haven’t really had time to track down all the bits and pieces needed.

My clients (HEOS and StreamMagic) can play the full playlist using the DirectoryObject as-is, so I’ve not had a huge need to solve this in the short term. But I can certainly take another look since it sounds like your client relies more heavily on this typing to work correctly.

cjustinhall commented 4 years ago

Just out of curiosity, do you use a value other than the defaults for the Plex host/port? Mostly trying to figure out why I don’t need it, but others might.

I've actually used both (localhost and the IP) and it doesn't matter.

I think the trick is b/c we have our account linked to Plex Home (or whatever it is called) so we can login via app.plex.tv - and this is where the Plex lifetime subscription is activated. Before I added the token change, I was getting 401 errors on all the playlist url calls.

Would love to see enhancements to the objects you discussed. Happy to help you test this. BTW I've looked high and low and your plugin is the ONLY way I've found to get playlists working inside of c4. You should advertise this fact :) Even the $200 plex full driver doesn't have playlist support. If this can get working.... you've got a market :)

cjustinhall commented 4 years ago

If this helps you, I put the driver in debug mode and viewed an Album (top) and then a Playlist (bottom) and you can see the difference in how the driver "sees" it ....

Album --

--- ReceivedFromProxy: 5001 SelectItem ----PARAMS---- ROOMID = 366 NAVID = c4-6635D6AB-3926-4CE9-9978-FA6611230F9F LOCALE = en-US SEQ = 47 -----ARGS----- album = Mark Schultz - 6 PICKS Essential Radio Hits EP image = http://192.168.1.x:32x/proxy/e2b199b2884628e67c38/albumart.jpg title = Mark Schultz - 6 PICKS Essential Radio Hits EP id = bcd5376e45426757e862 artist = By Album itemType = object.container.album.musicAlbum

--- ReceivedFromProxy: 5001 BrowseLibrary ----PARAMS---- ROOMID = 366 NAVID = c4-6635D6AB-3926-4CE9-9978-FA6611230F9F LOCALE = en-US SEQ = 48 -----ARGS----- itemType = object.container.album.musicAlbum start = 0 count = 50 screen = Collection id = bcd5376e45426757e862

When I look into a Playlist (from your plugin) --

--- ReceivedFromProxy: 5001 SelectItem ----PARAMS---- ROOMID = 366 NAVID = c4-6635D6AB-3926-4CE9-9978-FA6611230F9F LOCALE = en-US SEQ = 56 -----ARGS----- id = 61e6f3f4c7b2662bc214 image = http://192.168.1.x:32x/proxy/02f6c507d73d55c69cc7/albumart.jpg title = Performances itemType = object.container.storageFolder

--- ReceivedFromProxy: 5001 BrowseLibrary ----PARAMS---- ROOMID = 366 NAVID = c4-6635D6AB-3926-4CE9-9978-FA6611230F9F LOCALE = en-US SEQ = 57 -----ARGS----- itemType = object.container.storageFolder start = 0 count = 50 screen = All id = 61e6f3f4c7b2662bc214

cjustinhall commented 4 years ago

Additional bit of trivia to help get this working 👍

I looked into the DLNA driver that I'm using and it seems that if the item type is musicAlbum OR playlistContainer than a play all / shuffle all would work.

eg.

if (args.itemType == 'object.container.album.musicAlbum' or args.itemType == 'object.container.playlistContainer')

Thoughts on how to modify the objects to be a playlistContainer?

Kaiede commented 4 years ago

I figured that. Unfortunately, Plex doesn’t provide a PlaylistObject which would map to UPnP’s playlist container, which would make this easier.

Either have to figure out how to tag the ObjectContainer, and there’s a couple undocumented properties that may or may not be helpful here. Or have to figure out why my previous attempt using AlbumContainer didn’t do what I wanted.

I mostly haven’t worked on this yet due to lack of free time.

cjustinhall commented 4 years ago

Totally get this is a side hobby! (myself the same) No rush - just trying to give as much info as I can to help you.

If you have ideas/things to attempt pass along and I can take some stabs.

Kaiede commented 4 years ago

So it turns out there's an undocumented PlaylistObject, but I honestly have no idea if it does anything useful here. But it doesn't seem to make anything worse, so I pushed those changes to GitHub.

Can you see if it does anything for you?

cjustinhall commented 4 years ago

Hi - made the changes per the update, restarted plex, (ensured the changes were in effect) and unfortunately same result. Per debug logs on the driver, it is still seeing this as a storagefolder so no option to shuffle play.

Kaiede commented 4 years ago

So it looks like while it tells Plex that it is a playlist, Plex isn't passing that onto the client. Boo.

Another approach is to make this AlbumObjects, but there's definitely some stuff there I'd have to work through to make it work. It seems like things break if you don't provide enough detail in the Album that have to be debugged.