A Ruby Wrapper for the Plex Media Server API(s)

Hey all,



I just created a ruby gem for interfacing with the Plex API(s). I’ve decided to release it before its fully functional because honestly I’ve hit a wall.



I’ve implemented browsing the Plex Library and its now very easy to pull out all of your sections / shows / seasons / episodes / movies. The problem I’m having is with sending commands to the clients connected. The offending file can be read here. By following this slightly outdated guide by Jam, I’m fairly positive I’m doing the right thing. But when I call client.move_down nothing happens on the Media Player.



Heres what I get in the logs:



Dec 07, 2011 21:11:49 [0xb0aba000] DEBUG - Request: GET /system/players/Eric-Koslows-MacBook-Air/navigation/moveDown [127.0.0.1] (1 live)

Dec 07, 2011 21:11:49 [0xb0aba000] DEBUG - [com.plexapp.system] Sending command over HTTP (GET): /system/players/Eric-Koslows-MacBook-Air/navigation/moveDown

Dec 07, 2011 21:11:49 [0xb0aba000] DEBUG - HTTP request to: http://127.0.0.1:54701/system/players/Eric-Koslows-MacBook-Air/navigation/moveDown

Dec 07, 2011 21:11:49 [0xb0aba000] DEBUG - [com.plexapp.system] HTTP reply status 200, with 0 bytes of content.



It seems the server is getting the command, but its not passing it to the client?



This is happening for all of the commands, so once this is fix I’ll have a fully working Gem for everyone to use. Are there any Ruby people here that can take a look at my code, or someone better explain how the Remote Command API works.



Thank you everyone!

Wow, very nice work! Can you check your com.plexapp.system.log file? That should show whether it’s receiving the remote command, and what it’s doing in response.

At the same time in the com.plexapp.system.log I see



2011-12-07 21:11:49,769 (-4faed000) : DEBUG (runtime:528) - Handling request GET /system/players/Eric-Koslows-MacBook-Air/navigation/moveDown

2011-12-07 21:11:49,773 (-4faed000) : DEBUG (runtime:604) - Found route matching /system/players/Eric-Koslows-MacBook-Air/navigation/moveDown

2011-12-07 21:11:49,801 (-4faed000) : DEBUG (runtime:678) - Response: 200



So its getting the command, but nothing is happening?



Thank you Jam for looking into this!



EDIT



So I’m now in the office, and everything seems the be working. Same machine, but here it has a different name.



In the same log file here I am getting,



2011-12-08 09:15:23,934 (-4faed000) : DEBUG (runtime:528) - Handling request GET /system/players/koslow.office/navigation/moveDown

2011-12-08 09:15:23,943 (-4faed000) : DEBUG (runtime:604) - Found route matching /system/players/koslow.office/navigation/moveDown

2011-12-08 09:15:23,950 (-4faed000) : DEBUG (runtime:678) - Response: 200



So maybe this is a bug in my unique setup?



I’ve also found that while the navigation commands seem to be working, some of the application commands are still off. Like when I call server.clients.first.play_media(server.libary.section(2).all.first.key)



The log file shows



2011-12-08 09:18:07,822 (-4faed000) : DEBUG (runtime:528) - Handling request GET /system/players/koslow.office/application/playMedia?path=http%3A%2F%2Flocalhost%3A32400%2Flibrary%2Fmetadata%2F9&key=%2Flibrary%2Fmetadata%2F9

2011-12-08 09:18:07,824 (-4faed000) : DEBUG (runtime:604) - Found route matching /system/players/koslow.office/application/playMedia

2011-12-08 09:18:07,828 (-4faed000) : DEBUG (networking:115) - Requesting ‘http://koslow.office:3000/xbmcCmds/xbmcHttp?command=PlayMedia(http%3A//localhost%3A32400/library/metadata/9%3B/library/metadata/9%3B%2B%3B%20%3B%20)

2011-12-08 09:18:07,860 (-4faed000) : DEBUG (runtime:678) - Response: 200



But nothing happens in the media player.




EDIT 2



Disregard that second part, I realized that here I don’t have my external hard drive with my media, so of course nothing will happen when I try playing something. It would be nice if Plex gave you some kind of response in this situation :smiley:

Thanks a lot for your work !!

It’s something that will be very useful to me.



Do you consider (or maybe it’s already there) to implement api like ‘most recent episode seen’, ‘currently seen episode’ ?



Again, thanks !

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