phillipj / node-plex-control

Controlling Plex clients through the Plex Media Server HTTP API
MIT License
31 stars 6 forks source link

Needs control parameter to be a PlexControl instance! #31

Open Zefau opened 5 years ago

Zefau commented 5 years ago

Hi there,

thanks for the library. I'm just about to implement it and started retrieving clients as a first try via:

const PlexControl = require('plex-control').PlexControl;

let control = PlexControl('192.168.178.5');
control.getClients().then(res => console.log(JSON.stringify(res))).catch(e => console.error(e))

This fails with the error Needs control parameter to be a PlexControl instance!.

Looking up the source code at the specified line in the error trace brings me to:

https://github.com/phillipj/node-plex-control/blob/166657cc969b5d54f106e8cf4f35d9854470b3ab/lib/control.js#L26

Which hands 2 arguments to the function ExtensionHelper, which only expects one argument as it looks like? https://github.com/phillipj/node-plex-control/blob/166657cc969b5d54f106e8cf4f35d9854470b3ab/lib/ext-helper.js#L3

Am I doing something wrong or is it the code?

Thanks, Zefau

Zefau commented 5 years ago

It is only my stupidity. I forget new with the instantiation. Thus, instantiation works with

let control = new PlexControl('192.168.178.5');

This though brings me to:

Potentially unhandled rejection [1] TypeError: Cannot read property 'filter' of undefined
    at filterChildrenByCriterias (C:\Users\Zefau\Projects\plex\node_modules\plex-control\node_modules\plex-api\lib\api.js:309:21)
    at C:\Users\Zefau\Projects\plex\node_modules\plex-control\node_modules\plex-api\lib\api.js:144:16
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
TypeError: Cannot read property 'filter' of undefined
    at filterChildrenByCriterias (C:\Users\Zefau\Projects\plex\node_modules\plex-control\node_modules\plex-api\lib\api.js:309:21)
    at C:\Users\Zefau\Projects\plex\node_modules\plex-control\node_modules\plex-api\lib\api.js:144:16
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

Which is most likely caused by /clients not returning anything. If I call it directly from the browser it returns <MediaContainer size="0"></MediaContainer>.

Zefau commented 5 years ago

It's me again! I had to turn on Advertise as player in Plex Player Settings to have it available via /clients. Still facing the same error though.

Zefau commented 5 years ago

No luck getting this running. Eventually found this https://github.com/plexinc/plex-media-player/wiki/Remote-control-API#modified-commands and tried with all the parameters, but I'm only getting HTTP 400 all the time. :-(