Plex 9 remote API

Looks like this is a duplicate of http://forums.plexapp.com/index.php?/topic/15850-plex-9-remote-api/



Thanks!

Merged duplicate threads



Ha ha...I was a bit confused how that happened. I was actually about to make a post in here, but I don't think its necessary.


Got it working in CommandFusion today. I had to add carriage return (the "\x0D") to the new line ("\x0A"). Eg. the following is to send the "Pause" command:
"GET /system/players//playback/pause HTTP/1.1\x0D\x0AHost: :32400\x0D\x0A\x0D\x0A "

You ought to be able to create an AppleScript that starts Plex. I'm gonna try that next. [See http://applescript.tv/linktrigger/].

Alternatively, or as a backup, if you have a dedicated PlexMini, just set Plex as a startup item, and set that computer to restart every day at 4AM (or whenever suits your schedule.)

Has anyone been able to get PlayMedia to work? I had no problem with the navigation and pulling MediaContainers for all my movies and shows, but the PlayMedia part has me stumped.



Is the path always supposed to be of the form /library/sections// ? after drilling down into that, I eventually get a PMS URL like /library/metadata/8383/children, which describes all the different media files for the first season of one of the shows I have. I’ve tried constructing the PlayMedia URL using all kinds of combinations but nothing seems to work.



Something like /system/players//application/playMedia?path=/library/metadata/8383/children&key=7566 - 7566 is the id for the tag describing the actual file I am trying to play. This causes my client to pause for a second or two, and the HTTP Headers I receive are HTTP/1.1 200 OK, but then the client just resumes scrolling the newsfeed on the main screen just like it had been before loading the URL. I’ve also tried passing the ‘key’ parameter from the tag (which has the filename url-encoded at the end of it) but that doesn’t even produce a pause in the client. Any chance of a working example?




Quick question for you. I followed the wiki to the letter and still seem to be having issues. Here is what I have done.

Setup: Plex Server and iviewer

1. When I enter http://10.0.1.12:32400/system/players/Michael-Tathams-Mac-mini.local/navigation/moveDown into my browser it works and the cursor moves down.

2. I follwed the above HTTP Request Commands and came up with the following settings:

System Manager:

System Name: Plex Server
IP Address: 10.0.1.12
Port & Port Origin: 32400
TCP: selected

everything else is left blank


Command Properties

System: Plex Server 10.0.1.12
Command Name: Down
Command Value:
GET /system/players/Michael-Tathams-Mac-mini.local/navigation/moveUp HTTP/1.1\x0D\x0AHOST: 10.0.1.12:32400\x0D\x0A\x0D\x0A

everything else is left blank

3. I then went on to drag and drop the command to the appropriate button.

4. Saved and uploaded file.

5. No good ):

Any thoughts?



Never mind got it working. The file had not uploaded to my ipad correctly...had a weak signal.


How would one go about sending a keyboard letter stroke? would it be /sendKey/a/?

No, I'm pretty sure it would be like http://{server}:32400/system/players/{player}/application/sendString?text=a

I was able to get the screenshot thing to work with width and height specified using the same format, so I'm pretty sure that's how you'd do it.

Looks like sendKey takes a code, maybe ascii character code?



I finally got the basic commands working in Crestron. Now I just need help generating the correct html request to navigate to sections like music, and movies, and TV shows. Any ideas?

I tried sending the following command hoping that it would get me to the TV Shows folder:

http://{server}:32400/system/players/{player}/application/playMedia?/library/sections/2/

It didn't work however. Any advice would be greatly appreciated.

Also, Is there a list of sendKey commands somewhere? I just sent the command “http://{server}:32400/system/players/{player}/application/sendKey?code=13” and it effectively worked the same as pressing the select key.



I did it by accident thinking it would be the same as sending the letter S in ascii from the keyboard. It’s nice to know that the sendKey command works, but it would be nice to have a list of the available sendKey commands to work from.



Thanks in advance!


Well if you look at http://www.asciitable.com/, decimal 13 is the ascii code for carriage return, so it looks like it really is using an ascii code. The ascii code for lowercase s is 115, so try sending that instead.

I'm still hoping someone can figure out playMedia. I'll keep at it but I haven't had any luck yet. I'm almost positive you need to specify the arguments like so: playMedia?path=&key=.

That makes more sense. I would also like more info on the playMedia command.



for those interested here is what I eventually got working for the keyboard code- all ASCii


http://{server}:32400/system/players/{player}/application/sendVirtualKey?code=

8=delete
27=esc
32=space

48=0
49=1
50=2
51=3
52=4
53=5
54=6
55=7
56=8
57=9

97=a
98=b
99=c
100=d
101=e
102=f
103=g
104=h
105=i
106=j
107=k
108=l
109=m
110=n
111=o
112=p
113=q
114=r
115=s
116=t
117=u
118=v
119=w
120=x
121=y
122=z

Good deal. Thanks for sharing that. I might go back and change the protocol that I created for using the keyboard to match this. Much more efficient since it includes basic keyboard commands as well.

Here’s an example of using the PlayMedia command. Atomjack got it almost right, but missed a couple of things, probably because I rushed my previous explanation :slight_smile:



[list]

[]The ‘path’ argument needs to be a full HTTP URL, since the command is quite flexible (for example, it can be sent to computer A, instructing computer B to play a piece of media stored on computer C)

[
]The ‘key’ argument is the key of the


http://mac-mini.local:32400/system/players/imac.local/application/playMedia?path=http%3A%2F%2Fmac-mini.local%3A32400%2Flibrary%2Fsections%2F3%2FrecentlyAdded&key=%2Flibrary%2Fmetadata%2F3435

Jam, thanks for that description. Makes a lot more sense now!

Is it possible to issue a similar command to navigate to a specific folder, but not to play anything? In other words… From a control system like Crestron, can I send a command that would instantly navigate the Mac Mini in Plex to the Recently Added folder in movies, or to the Music plugin?

This interface is great! How can I send a fullscreen toggle? If I were to type it, I would use Cmd-F. Not sure how that would map to a virtual key code, though…

--------------------------

Update: Just did a run through of codes: Did it with:



http:// {server}:32400/system/players/{player}/application/sendVirtualKey?code=236





:smiley:




Is there a list of codes like this available for Plex?

I know there was a similar list for XBMC: http://xbmc.svn.sourceforge.net/viewvc/xbmc/trunk/guilib/Key.h?view=markup

I know the devs are busy with the new rollout, but it would be awesome if there were a list of commands available to work from.