Author Topic: Plex  (Read 4021 times)

0 Members and 1 Guest are viewing this topic.

Dominique

  • Jr. Member
  • **
  • Posts: 41
  • Karma: -1
    • View Profile
Plex
« on: May 24, 2020, 01:55:12 AM »
Plex hasnt been brought up in a while.  I do not really use Kodi/XBMC primarily because I dont really care for dealing with repos, channels, etc.  I like Plex because it simply works without dealing with any of that.

Anyhow, Plex (client not server) runs off a web browser with an localaddress: port: just like the Google Speech API.  Having said that, in theory it should be doable to get VC to control it.

Has anyone ever gotten Plex to work?  I did a forum search before posting this and did not see any integrations. 

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Plex
« Reply #1 on: May 25, 2020, 01:27:16 PM »
Unfortunately, as far as we know no one has been able to figure out the Plex API for remote control. 

Their documentation is garbage and I don't even know if it works.  Attempts that I have made to play a movie come back with "400 Bad Request" with absolutely no other information to go on.

Dominique

  • Jr. Member
  • **
  • Posts: 41
  • Karma: -1
    • View Profile
Re: Plex
« Reply #2 on: May 26, 2020, 06:09:53 PM »
Unfortunately, as far as we know no one has been able to figure out the Plex API for remote control. 

Their documentation is garbage and I don't even know if it works.  Attempts that I have made to play a movie come back with "400 Bad Request" with absolutely no other information to go on.

Thats unfortunate.  I combed through their forum and may have found a solution.  I just dont know how to implement it.

https://forums.plex.tv/t/remote-plex-access-not-working-error-parsing-http-request/33456/7

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Plex
« Reply #3 on: May 27, 2020, 01:05:16 PM »
I don't see how that applies.

One of the main problems is that the Plex API is mostly undocumented and has gone through a few transitions over the years so even when you think you've found something useful it often does not work anymore.

Another problem is that even using their own programs, the ability to control other clients can be quite hit and miss and is inconsistent in terms of which clients are willing to respond to which types of commands.

I spent a few hours trying to reverse engineer what the Plex web client sends when trying to control other clients and have made a bit of progress.  One issue I have found that could be a huge problem is that the Plex Media Player for Windows does not seems to be reliably "available" for other clients to control.  So you may be able to give it one command and then suddenly it will disappear.

Then there are other clients such as Roku, Chromecast (which I do not have access to), and I think a client for Kodi which is probably not even worth thinking about.

What client do you normally use with Plex?  So far the only client that seems to be reliable for me is the web client on Chrome.
« Last Edit: May 28, 2020, 09:09:25 AM by nime5ter »

Dominique

  • Jr. Member
  • **
  • Posts: 41
  • Karma: -1
    • View Profile
Re: Plex
« Reply #4 on: May 29, 2020, 04:30:19 AM »
I don't see how that applies.

One of the main problems is that the Plex API is mostly undocumented and has gone through a few transitions over the years so even when you think you've found something useful it often does not work anymore.

Another problem is that even using their own programs, the ability to control other clients can be quite hit and miss and is inconsistent in terms of which clients are willing to respond to which types of commands.

I spent a few hours trying to reverse engineer what the Plex web client sends when trying to control other clients and have made a bit of progress.  One issue I have found that could be a huge problem is that the Plex Media Player for Windows does not seems to be reliably "available" for other clients to control.  So you may be able to give it one command and then suddenly it will disappear.

Then there are other clients such as Roku, Chromecast (which I do not have access to), and I think a client for Kodi which is probably not even worth thinking about.

What client do you normally use with Plex?  So far the only client that seems to be reliable for me is the web client on Chrome.

I usually use Chormecast or my ps4.   

Dominique

  • Jr. Member
  • **
  • Posts: 41
  • Karma: -1
    • View Profile
Re: Plex
« Reply #5 on: June 05, 2020, 05:53:57 AM »
James how long ago did you make attempt at a Plex integration?  I saw on my dashboard an option for webhooks.



This is their documentation  https://support.plex.tv/articles/115002267687-webhooks/?utm_campaign=Plex%20Apps&utm_medium=Plex%20Web&utm_source=Plex%20Apps

Code: [Select]
Webhook Events
There are several events which cause webhooks to be hit, along with the name of the events in the payload:

New Content
library.on.deck – A new item is added that appears in the user’s On Deck. A poster is also attached to this event.
library.new – A new item is added to a library to which the user has access. A poster is also attached to this event.

Playback
media.pause – Media playback pauses.
media.play – Media starts playing. An appropriate poster is attached.
media.rate – Media is rated. A poster is also attached to this event.
media.resume – Media playback resumes.
media.scrobble – Media is viewed (played past the 90% mark).
media.stop – Media playback stops.

Server Owner
These events are sent only for the server owner/admin account and relate to events on the server in general.

admin.database.backup – A database backup is completed successfully via Scheduled Tasks.
admin.database.corrupted – Corruption is detected in the server database.
device.new – A device accesses the owner’s server for any reason, which may come from background connection testing and doesn’t necessarily indicate active browsing or playback.
playback.started – Playback is started by a shared user for the server. A poster is also attached to this event.

Webhook Payload
The payload consists of five different parts.

Top-level: This contains event, user, and owner attributes. The event attribute holds the name of the event, as specified above. The user and owner flags indicate whether the event is sent because the user has a webhook configured (user flag is set) or because the server owner has a webhook set (the owner flag is set). This can be very useful for certain scenarios. Note that if a server owner triggers an event, both user and owner flags will be set.
Account: The account object contains information about the user who triggered the event, including ID, title, and in some cases, a URL for the user’s avatar image. Note that the owner ID will always be 1.

Server: The server object contains information about the server from which the event was generated, including the title and UUID.
Player: The player object contains information about the player which generated the event, if applicable. It contains the title of the player, its UUID, the public IP address of the player, and a local flag indicating whether or not it was on the same network as the server.
Metadata: This last object contains detailed information about the media.

With the details available in the payload, it’s possible for a webhook receiver to perform detailed filtering on the events. It may want to only look for events for a single player, or a single user, or all players local to the server, e.g.

As stated above, the payload is sent in JSON format inside a multipart HTTP POST request. For the media.play and media.rate events, a second part of the POST request contains a JPEG thumbnail for the media.

Example Payload
Here is an example payload:


   "event": "media.play",
   "user": true,
   "owner": true,
   "Account": {
      "id": 1,
      "thumb": "https://plex.tv/users/1022b120ffbaa/avatar?c=1465525047",
      "title": "elan"
   },
   "Server": {
      "title": "Office",
      "uuid": "54664a3d8acc39983675640ec9ce00b70af9cc36"
   },
   "Player": {
      "local": true,
      "publicAddress": "200.200.200.200",
      "title": "Plex Web (Safari)",
      "uuid": "r6yfkdnfggbh2bdnvkffwbms"
   },
   "Metadata": {
      "librarySectionType": "artist",
      "ratingKey": "1936545",
      "key": "/library/metadata/1936545",
      "parentRatingKey": "1936544",
      "grandparentRatingKey": "1936543",
      "guid": "com.plexapp.agents.plexmusic://gracenote/track/7572499-91016293BE6BF7F1AB2F848F736E74E5/7572500-3CBAE310D4F3E66C285E104A1458B272?lang=en",
      "librarySectionID": 1224,
      "type": "track",
      "title": "Love The One You're With",
      "grandparentKey": "/library/metadata/1936543",
      "parentKey": "/library/metadata/1936544",
      "grandparentTitle": "Stephen Stills",
      "parentTitle": "Stephen Stills",
      "summary": "",
      "index": 1,
      "parentIndex": 1,
      "ratingCount": 6794,
      "thumb": "/library/metadata/1936544/thumb/1432897518",
      "art": "/library/metadata/1936543/art/1485951497",
      "parentThumb": "/library/metadata/1936544/thumb/1432897518",
      "grandparentThumb": "/library/metadata/1936543/thumb/1485951497",
      "grandparentArt": "/library/metadata/1936543/art/1485951497",
      "addedAt": 1000396126,
      "updatedAt": 1432897518
   }
}

Sample Code
We’ve made a few sample projects available so that you can see the sorts of things you can build using webhooks.
« Last Edit: June 05, 2020, 10:00:57 AM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Plex
« Reply #6 on: June 05, 2020, 10:12:23 AM »
James how long ago did you make attempt at a Plex integration?  I saw on my dashboard an option for webhooks.

I'm working on one now but it is very slow going for reasons I have previously explained.

The "webhooks" are a premium feature of Plex (you have to pay a subscription to use).

The webhooks are used to send events to other applicatitons.  They don't allow you to control Plex at all.

You can use these now without any plugin required.  It's just a question of setting it up to send messages to VC, presumably via the TCP plugin.  But again, this won't allow you to control Plex in any way.  It will allow you to do things such as dim the lights when a movie starts, or use TTS to announce when things happen in Plex like when a new movie is added to the database etc.