Hello,
I’m looking for some help with playing a specific piece of media (TV Show episode or Movie) remotely through an HTTP request. I’m currently using the following PHP API: github.com/nickbart/php-plex.
Here is the code I use to initialize the API:
$servers = array(
    'jaszzz' => array(
        'address' => '[SERVER_IP]'
    )
);
$plex = new Plex();
$plex->registerServers($servers);
$server = $plex->getServer('jaszzz');
$client = $plex->getClient('[ROKU_UNIQUE_ID]');
$playback = $client->getPlaybackController();
$application = $client->getApplicationController();
I’m able to successfully call the Pause and Play functions:
$playback->pause();
$playback->play();
The API generates the below URLs:
http://[SERVER_IP]:[SERVER_PORT]/system/players/[ROKU_IP]/playback/pause
http://[SERVER_IP]:[SERVER_PORT]/system/players/[ROKU_IP]/playback/play
Here is the code I’m trying to use to get a movie entity within my server, and start playback at the beginning of the entity:
$section = $server->getLibrary()->getSection('Movies');
$movie = $section->getMovie('[MOVIE_NAME]');
$application->playMedia($movie);
The API generates the below URL:
http://[SERVER_IP]:[SERVER_PORT]/system/players/[ROKU_IP]/application/playMedia?key=/library/metadata/17150&path=http://[SERVER_IP]:[SERVER_PORT]/library/metadata/17150
When I go to this URL manually, I get the following XML response:
<Response code="2000" status="HTTPError: ">
<Traceback>
Traceback (most recent call last): File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 843, in handle_request result = f(**d) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/System.bundle/Contents/Code/playerservice.py", line 67, in process_legacy_remote_command result = cmd(**kwargs) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 19, in _apply return apply(f, args, kwargs) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/playerkit.py", line 395, in f return req.content File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 265, in content return self.__str__() File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 243, in __str__ self.load() File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 181, in load f = self._opener.open(req, timeout=self._timeout) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 444, in open response = meth(req, response) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 557, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 482, in error return self._call_chain(*args) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 416, in _call_chain result = func(*args) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 565, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) HTTPError: HTTP Error 400: Bad Request
</Traceback>
</Response>
I read here that “playMedia” is a “playback” command, rather than an “application” command. I swapped out the commands in the API so that application was replaced with playback - generated URL below:
http://[SERVER_IP]:[SERVER_PORT]/system/players/[ROKU_IP]/playback/playMedia?key=/library/metadata/17150&path=http://192.168.0.117:32400/library/metadata/17150
Resulting XML response:
<Response code="2000" status="BadStatusLine: ">
<Traceback>
Traceback (most recent call last): File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 843, in handle_request result = f(**d) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/System.bundle/Contents/Code/playerservice.py", line 67, in process_legacy_remote_command result = cmd(**kwargs) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 19, in _apply return apply(f, args, kwargs) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/playerkit.py", line 395, in f return req.content File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 265, in content return self.__str__() File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 243, in __str__ self.load() File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 181, in load f = self._opener.open(req, timeout=self._timeout) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 438, in open response = self._open(req, data) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 456, in _open '_open', req) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 416, in _call_chain result = func(*args) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 1217, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 1190, in do_open r = h.getresponse() File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/httplib_new.py", line 1030, in getresponse response.begin() File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/httplib_new.py", line 431, in begin version, status, reason = self._read_status() File "/usr/lib/plexmediaserver/Resources/Plug-ins-9394c87/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/httplib_new.py", line 419, in _read_status raise BadStatusLine(line) BadStatusLine: HTTP/1.1 0
</Traceback>
</Response>
Roku logs and Plex logs yield no helpful information that I can see. Let me know if you need any other information to help me with this.
Thanks in advance for your help!