Making PseudoTV functionality in Plex

Hopefully this can be a master thread for all the work that goes in to making PseudoTV work in Plex.

 

 

Here's the plan so far:

 

  1. Have PseudoTV read the library from Plex
  2. Create a playlist just like it does in XBMC, then update that playlist live in Plex
  3. When you want to watch "TV", simply choose the appropriate playlist

 

Examples:

  • Plex > Server > Playlist > AMC
  • Plex > Server > Playlist > Action Movies
  • Plex > Server > Playlist > Children's TV

 

To keep up with scheduling, the PseudoTV backend could update the playlist regularly, therefore serving the "scheduled" video when the user chooses it.

 

 

 

Work to be done:

  • Decipher how Playlists work in Plex #It looks like this is all handled in the database
  • Connect Library and Playlists to a PseudoTV backend
  • Have a way to configure the PseudoTV backend #The obvious choice for this is web, but we're not limited

 

 

I'm open to moving this discussion to http://raspberrypihtpc.wordpress.com if we get noisy, and in that spirit, anyone who's interested in helping post anything that interesting to you and once the pieces are all on the table, we'll put them together!

 

Edit: When creating a playlist, there is a wait before the playlist is written to the database file, so give it 2 minutes or so just to be safe before looking in to it.

Notes:

Using the same process to access the database as shown on http://raspberrypihtpc.wordpress.com/how-to/how-to-plex-media-server-change-the-section-icons/ , I started digging around the database and found these tables:

  • play_queue_generators
  • play_queue_items
  • play_queues

I did not find any files in the Application Support folder that contained the name of the playlist, nor were there any filesystem changes detected when creating a playlist.

Here's an example of an entry for the play_queue_generators table where the playlist_id matches the id from the plex url (in this case "/playlist/5688"):

"id","playlist_id","metadata_item_id","url","limit","continuous","order","created_at","updated_at"
"135","5688","1691","",,,"3000","2014-08-25 15:07:08","2014-08-25 15:07:08"

Each entry in the playlist seems to have it's own row in this table.

Note: the "metadata_item_id" of 1691 looked up in the "metadata_items" tables matches the episode that is in the playlist.

Since this is all in the database, there are two challenges coming up on the horizon:

  1. The PseudoTV backend, if it accesses the database directly, will have to check if the database is locked by Plex, and if it is, to wait until the database is unlocked before locking it to do it's work
  2. on XBMC, PseudoTV lets you channel flip through different parts of the show. Plex may not support this yet

One caveat:

It's very easy to corrupt the database while testing things out, and a corrupt database is not always obvious.

-Stopped Plex, added an entry to the play_queue_generators table, double-checked the file permissions, and started Plex again

-Plex never complained

-The WebUI and iOS app did not show the deck, but other than that they seemed to work

-No videos played through Plex/Web, iOS, or PlexHT. The Roku app was fine.

I looked for insight in the logs before simply assuming that the DB was corrupt and replacing it with the backup.

Of course, everything was back to normal after that.

A friendly hint. You should not use direct access to the database, we have a API that you can use to create the playlists. You can either 1) watch network traffic from Plex/Web when modifying the playlist to get a sense of it. 2) Look at PHT's source code when it starts supporting playlists (it currently only supports playQueues, which are tied to playlists).

You may also notice that PseudoTV is mentioned in a number of threads in the feature request forum...

A friendly hint. You should not use direct access to the database, we have a API that you can use to create the playlists. You can either 1) watch network traffic from Plex/Web when modifying the playlist to get a sense of it. 2) Look at PHT's source code when it starts supporting playlists (it currently only supports playQueues, which are tied to playlists).

Aha! Exactly the kind of information that I was hoping for by posting the first few fumbling steps.

Using the Chrome web tools to watch network traffic while manipulating a playlist, it seems to be fairly straightforward.

In the interests of sharing, here's an example of adding an item to a playlist:

items?uri=library%3A%2F%2FPRIVATE%2Fitem%2F%252Flibrary%252Fmetadata%252F5297
192.168.0.100/playlists/5848
?X-Plex-Client-Identifier=PRIVATE&X-Plex-Product=Plex+Web&X-Plex-Device=OSX&X-Plex-Platform=Chrome&X-Plex-Platform-Version=39.0&X-Plex-Version=2.2.4&X-Plex-Device-Name=Plex+Web+(Chrome)&X-Plex-Token=PRIVATE&X-Plex-Username=jackandjohn
162.243.67.114
3 requests ❘ 1.1 KB transferred
HeadersPreviewResponseTiming
Remote Address:192.168.0.100:32400
Request URL:http://192.168.0.100:32400/playlists/5848/items?uri=library%3A%2F%2FPRIVATE%2Fitem%2F%252Flibrary%252Fmetadata%252F5297
Request Method:PUT
Status Code:200 OK
Request Headersview source
Accept:text/plain, /; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Host:192.168.0.100:32400
Origin:http://plex.tv
Referer:http://plex.tv/web/app
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2138.3 Safari/537.36
X-Plex-Client-Identifier:PRIVATE
X-Plex-Device:OSX
X-Plex-Device-Name:Plex Web (Chrome)
X-Plex-Platform:Chrome
X-Plex-Platform-Version:39.0
X-Plex-Product:Plex Web
X-Plex-Token:PRIVATE
X-Plex-Username:jackandjohn
X-Plex-Version:2.2.4
Query String Parametersview sourceview URL encoded
uri:library://PRIVATE/item/%2Flibrary%2Fmetadata%2F5297
Response Headersview source
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Location
Cache-Control:no-cache
Connection:close
Content-Encoding:gzip
Content-Length:320
Content-Type:text/xml;charset=utf-8
X-Plex-Content-Compressed-Length:320
X-Plex-Content-Original-Length:489
X-Plex-Protocol:1.0 

And here's removing an item from the same playlist:

Remote Address:192.168.0.100:32400
Request URL:http://192.168.0.100:32400/playlists/5848/items/194
Request Method:DELETE
Status Code:200 OK
Request Headersview source
Accept:text/plain, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:192.168.0.100:32400
Origin:http://plex.tv
Referer:http://plex.tv/web/app
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2138.3 Safari/537.36
X-Plex-Client-Identifier:PRIVATE
X-Plex-Device:OSX
X-Plex-Device-Name:Plex Web (Chrome)
X-Plex-Platform:Chrome
X-Plex-Platform-Version:39.0
X-Plex-Product:Plex Web
X-Plex-Token:PRIVATE
X-Plex-Username:jackandjohn
X-Plex-Version:2.2.4
Response Headersview source
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Location
Cache-Control:no-cache
Connection:close
Content-Encoding:gzip
Content-Length:301
Content-Type:text/xml;charset=utf-8
X-Plex-Content-Compressed-Length:301
X-Plex-Content-Original-Length:441
X-Plex-Protocol:1.0

And here's deleting a whole playlist:

5848
192.168.0.100/playlists
?X-Plex-Client-Identifier=PRIVATE&X-Plex-Product=Plex+Web&X-Plex-Device=OSX&X-Plex-Platform=Chrome&X-Plex-Platform-Version=39.0&X-Plex-Version=2.2.4&X-Plex-Device-Name=Plex+Web+(Chrome)&X-Plex-Token=PRIVATE&X-Plex-Username=jackandjohn
162.243.67.114
2 requests ❘ 202 B transferred
HeadersPreviewResponseTiming
Remote Address:192.168.0.100:32400
Request URL:http://192.168.0.100:32400/playlists/5848
Request Method:DELETE
Status Code:200 OK
Request Headersview source
Accept:text/plain, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:192.168.0.100:32400
Origin:http://plex.tv
Referer:http://plex.tv/web/app
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2138.3 Safari/537.36
X-Plex-Client-Identifier:PRIVATE
X-Plex-Device:OSX
X-Plex-Device-Name:Plex Web (Chrome)
X-Plex-Platform:Chrome
X-Plex-Platform-Version:39.0
X-Plex-Product:Plex Web
X-Plex-Token:PRIVATE
X-Plex-Username:jackandjohn
X-Plex-Version:2.2.4
Response Headersview source
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Location
Cache-Control:no-cache
Connection:close
Content-Length:0
Content-Type:text/html
X-Plex-Protocol:1.0

It looks like the basics for PseudoTV would be:

  1. Grab a list of items that are going to be in the playlist, keeping track of the ID of each item
  2. Wipe the current Playlist, since it would contain an old schedule ( http://server:32400/playlists/PseudoTVPlaylistID , Request method DELETE )
  3. Recreate the playlist, and populate it with the current schedule ( http://server:32400/playlists/PseudoTVPlaylistID/items?uri=library%3A%2F%2FPRIVATE%2Fitem%2F%252Flibrary%252Fmetadata%252FItemID , Request method PUT )

I'm keen to help with this however possible. I've run PseudoTV (and the Live fork) quite extensively in the past and have a good working knowledge of it and Plex. Not sure where this is at just now or if the purpose of this is to feed back to Plex devs, but it's a really great potential addition.

So, now that playlists seem to be in full swing in Plex, is anyone working on reviving this? 

+1
i second this

@crablin said:
I’m keen to help with this however possible. I’ve run PseudoTV (and the Live fork) quite extensively in the past and have a good working knowledge of it and Plex. Not sure where this is at just now or if the purpose of this is to feed back to Plex devs, but it’s a really great potential addition.

Are you still keen to help?
If so, what do you think would be a good method for how it would work?

Really hope this still has traction, would be a killer feature for Plex!

The way PMS does channels is by web based m3u playlists. The way existing Channels functionality is defined, it doesn’t lend itself to a traditional EPG. The DVR side does have it’s own program guide methodology, but since the conventional cable box program guide layout and functionality is copy-written… it wasn’t used.
However, it seems to me, the logical thing would be to add some code to leverage existing playlist logic and existing program guide logic, have a streamlined means to a smashing new feature.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.