node-plex-api icon indicating copy to clipboard operation
node-plex-api copied to clipboard

Broken with recent Plex version

Open daguej opened this issue 8 years ago • 8 comments

Running against PMS 1.4.1.3362, immediately after instantiating a new PlexControl:

TypeError: Cannot read property 'filter' of undefined
    at filterChildrenByCriterias (my-project/node_modules/plex-api/lib/api.js:261:20)
    at my-project/node_modules/plex-api/lib/api.js:130:16
    at _fulfilled (my-project/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (my-project/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (my-project/node_modules/q/q.js:796:13)
    at my-project/node_modules/q/q.js:604:44
    at runSingle (my-project/node_modules/q/q.js:137:13)
    at flush (my-project/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Was working prior to upgrading Plex.

daguej avatar Mar 09 '17 06:03 daguej

I'm guessing it is related to the new format introduced in Plex v1.3: https://github.com/phillipj/node-plex-api/issues/75

phillipj avatar Mar 09 '17 07:03 phillipj

I've got the same, running Version 1.5.4.3596. Any progress on this? :)

EDIT: Noticed it only happened when using client.find("/") for me, using query works fine.

Tommatheussen avatar Apr 13 '17 12:04 Tommatheussen

Having the same issue. Always results in the same error whatever I try to do with plex-control. I am using Plex 1.6.1.3722

thomasvnl avatar May 18 '17 11:05 thomasvnl

Hi think the api doesn´t work, because nobody close this issue? Using plex-media-server 1.9.3.4290

Eisbaeeer avatar Oct 02 '17 07:10 Eisbaeeer

@Eisbaeeer I'd assume you're correct. Mostly because of me that obviously doesn't find the time to prioritise working on it.

That said, anyone who's willing to contribute are more than welcome.

phillipj avatar Oct 02 '17 12:10 phillipj

use client.query directly

const movieSectionURL = "/library/sections/1/all" ;

client.query(movieSectionURL).then(function (result) {
    //console.log( result.MediaContainer );
    const {
        Metadata
    } = result.MediaContainer;

    // Metadata.map(item => {
    //     console.log(item)
    //     console.log('---------------------------------')
    // });

    console.log(Metadata[0].Media[0])

}, function (err) {
    console.error("Could not connect to server", err);
});

prints:

{ videoResolution: '1080',
  id: 3494,
  duration: 6722027,
  bitrate: 2256,
  width: 1920,
  height: 800,
  aspectRatio: 2.35,
  audioChannels: 2,
  audioCodec: 'aac',
  videoCodec: 'h264',
  container: 'mp4',
  videoFrameRate: '24p',
  optimizedForStreaming: 1,
  audioProfile: 'lc',
  has64bitOffsets: false,
  videoProfile: 'high',
  Part:
   [ { id: 7832,
       key: '/library/parts/7832/1463945897/file.mp4',
       duration: 6722027,
       file: '/Volumes/starck/movies/Thor 2 (2013)The Dark World.mp4',
       size: 1895918175,
       audioProfile: 'lc',
       container: 'mp4',
       has64bitOffsets: false,
       hasChapterTextStream: true,
       optimizedForStreaming: true,
       videoProfile: 'high' } ] }

boostup avatar Dec 09 '17 20:12 boostup

https://github.com/phillipj/node-plex-api/blob/3cd51abe9ceb5e21335762ef66cf9bfa8cc943ad/lib/api.js#L144

Change to this :

result._children = result._children || result.MediaContainer.Directory; 
return filterChildrenByCriterias(result._children, criterias);

PS.- Will only work for all those keys in Directory...

xochilpili avatar Jan 04 '19 07:01 xochilpili

With #92 merged, this should be improved quite a lot.

Don't hesitate reporting more still-failing queries, if you've got the response from the Plex Media Server as well, that would be extremely helpful.

phillipj avatar Aug 20 '19 10:08 phillipj