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

**URL:** <https://forums.plex.tv/t/a-ruby-wrapper-for-the-plex-media-server-api-s/13059>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [December 8, 2011, 2:40am UTC](https://forums.plex.tv/t/a-ruby-wrapper-for-the-plex-media-server-api-s/13059 "2011-12-08T02:40:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ekosz](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@ekosz](https://forums.plex.tv/u/ekosz)\
**Post date:** [December 8, 2011, 2:40am UTC](https://forums.plex.tv/t/a-ruby-wrapper-for-the-plex-media-server-api-s/13059/1 "2011-12-08T02:40:24Z")

</div>

Hey all,  
  
  
  
I just created [a ruby gem](https://github.com/ekosz/Plex-Ruby) 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](https://github.com/ekosz/Plex-Ruby/blob/master/lib/plex-ruby/client.rb). By following [this slightly outdated guide](http://forums.plexapp.com/index.php/topic/15850-plex-9-remote-api/page __p__ 101671#entry101671) 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](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!

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [December 8, 2011, 8:09am UTC](https://forums.plex.tv/t/a-ruby-wrapper-for-the-plex-media-server-api-s/13059/2 "2011-12-08T08:09:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ekosz](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@ekosz](https://forums.plex.tv/u/ekosz)\
**Post date:** [December 8, 2011, 2:14pm UTC](https://forums.plex.tv/t/a-ruby-wrapper-for-the-plex-media-server-api-s/13059/3 "2011-12-08T14:14:18Z")

</div>

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)](http://koslow.office:3000/xbmcCmds/xbmcHttp?command=PlayMedia%28http%3A//localhost%3A32400/library/metadata/9%3B/library/metadata/9%3B%2B%3B%20%3B%20%29)’  
  
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 😃

---

<div class="post-metadata">

**Author:** ![liero](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@liero](https://forums.plex.tv/u/liero)\
**Post date:** [January 5, 2012, 10:09am UTC](https://forums.plex.tv/t/a-ruby-wrapper-for-the-plex-media-server-api-s/13059/4 "2012-01-05T10:09:42Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 9:30pm UTC](https://forums.plex.tv/t/a-ruby-wrapper-for-the-plex-media-server-api-s/13059/5 "2019-12-20T21:30:05Z")

</div>

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