From 85e72492634b944ad9e96b72dee5df726e2b714e Mon Sep 17 00:00:00 2001 From: Wifsimster Date: Sun, 11 Aug 2019 15:24:40 +0200 Subject: [PATCH] Update readme --- README.md | 98 ++++++++++++++++--------------------------------- pavie.js | 77 ++++++-------------------------------- test/tv-show.js | 15 ++++++++ 3 files changed, 58 insertions(+), 132 deletions(-) create mode 100644 test/tv-show.js diff --git a/README.md b/README.md index 01f3b1f..33ddaf7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pavie -Node.js restful API for Plex Media Server. +Node.js SDK for the Plex Media Server API. Tested on Plex Media Server v1.16.3. @@ -11,9 +11,7 @@ Tested on Plex Media Server v1.16.3. ## Summary -[Libraries](https://github.com/Wifsimster/pavie#libraries) - -[Directories](https://github.com/Wifsimster/pavie#directories) +[Metadata](https://github.com/Wifsimster/pavie#metadata) [Synchronize](https://github.com/Wifsimster/pavie#synchronize) @@ -21,8 +19,6 @@ Tested on Plex Media Server v1.16.3. [History](https://github.com/Wifsimster/pavie#history) -[Metadata](https://github.com/Wifsimster/pavie#metadata) - [Images](https://github.com/Wifsimster/pavie#images) ## Install @@ -50,8 +46,6 @@ pavie ## Documentation -### Instance methods - #### signin() Authenticate user to Plex server. This is the first method to call, this instantiate your server and your token for the others methods ! @@ -79,50 +73,53 @@ Get the list actions availables. ie : platform, platformVersion, updatedAt, version, machineIdentifier, myPlexUsername. Return : [activities, butler, channels, clients, devices, diagnostics, hubs, library, livetv, media, player, playlists, resources, search, server, ...]. -#### getMedatadata([id]) - -Get metdata of a media. - #### getServers() Get a list of servers. Return: [name, host, address, port, machineIdentifier, version]. -### Libraries +### Metadata -#### getLibraries() +### getMetadata([id]) -Get a list of libraries. -Return: [section, recentlyAdded, onDeck]. +Return all info about a media. -#### getLibrary([library = 'sections']) +- `id` `` Identifiant -Get a list of sections in the library. -Return: [Movies, Music, TV Shows]. +### getMetadataChildren([id], [options]) -#### refresh([library = 'sections'], [sectionId = 2]) +Return all children metadata for a specified media. +ie: Returnn seasons metadata for a specified Tv Show. -Refresh a section. +- `id` `` Identifiant +- `options` `` + - `excludeAllLeaves` ``, default: `1` + +### getRelated([id], [options]) + +Return a list of related media. -### Directories +- `id` `` Identifiant +- `options` `` + - `excludeFields` ``, default: `summary` + - `includeExternalMetadata` ``, default: `1` + - `asyncAugmentMetadata` ``, default: `1` -#### getDirectoriesFromSection([library = 'sections'], [sectionId = 2]) +### getSimilar([id]) -Get list of directory in a specified section. -Default : TV Shows section. -Return : [all, unwatched, newest, recentlyAdded, recenntlyViewed, recentlyViewedShows, onDeck, folder, ...] +Return a list of similar media. -#### getDirectory([library = 'sections'], [sectionId = 2], [directory = 'all']) +- `id` `` Identifiant -Get a list of TV Shows by directory. -Default : TV Shows and all. -Return : [studio, type, title, contentRating, summary, index, rating, year, thumb, art, duration, originallyAvailableAt, ...]. +### search([query], [options]) -#### search([library = 'sections'], [sectionId = 2], [filters = { type: 2}]) +Global search of media. -Search Tv Shows, episodes, movies or musics. -Default : [sectionId : Tv Shows, type: Tv Shows] -For Tv Shows, type: [2: Tv Shows, 3: Seasonn, 4 : Episode] +- `query` `` +- `options` `` + - `includeCollections` ``, default: `1` + - `sectionId` `` + - `limit` ``, ie: `30` ### Synchronize @@ -195,39 +192,6 @@ Get the history of a TV Shows. - `metadataItemID` `` Identifiant - `sort` `` Order by, default : `viewed:desc` - ### Metadata - - ### getMetadata([id]) - - Return all info about a media. - - - `id` `` Identifiant - - ### getMetadataChildren([id], [options]) - - Return all children metadata for a specified media. - ie: Returnn seasons metadata for a specified Tv Show. - - - `id` `` Identifiant - - `options` `` - - `excludeAllLeaves` ``, default: `1` - - ### getRelated([id], [options]) - - Return a list of related media. - - - `id` `` Identifiant - - `options` `` - - `excludeFields` ``, default: `summary` - - `includeExternalMetadata` ``, default: `1` - - `asyncAugmentMetadata` ``, default: `1` - - ### getSimilar([id]) - - Return a list of similar media. - - - `id` `` Identifiant - ### Images #### getImage([url], [options]) diff --git a/pavie.js b/pavie.js index 2282f43..3e46ccd 100644 --- a/pavie.js +++ b/pavie.js @@ -117,71 +117,6 @@ module.exports = class { } } - /** - * Get a list of libraries - * Return: [section, recentlyAdded, onDeck] - */ - async getLibraries() { - const response = await this.instance.get("/library") - - if (response.status < 400) { - return response.data.MediaContainer - } - } - - /** - * Get a list of sections in the library - * Return: [Movies, Music, TV Shows] - */ - async getLibrary(library = "sections") { - const response = await this.instance.get(`/library/${library}`) - - if (response.status < 400) { - return response.data.MediaContainer - } - } - - /** - * Get list of directory in a specified section - * Default : TV Shows section - * Return : [all, unwatched, newest, recentlyAdded, recenntlyViewed, recentlyViewedShows, onDeck, folder, ...] * - */ - async getDirectoriesFromSection(library = "sections", sectionId = 2) { - const response = await this.instance.get(`/library/${library}/${sectionId}`) - - if (response.status < 400) { - return response.data.MediaContainer - } - } - - /** - * Get a list of TV Shows by directory - * Default : TV Shows and all - * Return : [studio, type, title, contentRating, summary, index, rating, year, thumb, art, duration, originallyAvailableAt, ...] - */ - async getDirectory(library = "sections", sectionId = 2, directory = "all") { - const response = await this.instance.get(`/library/${library}/${sectionId}/${directory}`) - - if (response.status < 400) { - return response.data.MediaContainer - } - } - - /** - * Search Tv Shows, episodes, movies or musics - * Default : [sectionId : Tv Shows, type: Tv Shows] - * For Tv Shows, type: [2: Tv Shows, 3: Seasonn, 4 : Episode] - */ - async search(library = "sections", sectionId = 2, filters = { type: 2 }) { - const response = await this.instance.get( - `/library/${library}/${sectionId}/search?${querystring.stringify(filters)}` - ) - - if (response.status < 400) { - return response.data.MediaContainer - } - } - /** * Refresh a section */ @@ -386,4 +321,16 @@ module.exports = class { return response.data } } + + /** + * Global search + */ + async search(query, options = {}) { + options = Object.assign({ includeCollections: 1, sectionId: null, limit: null, query: query }, options) + const response = await this.instance.get(`/hubs/search?${querystring.stringify(options)}`) + + if (response.status < 400) { + return response.data.MediaContainer + } + } } diff --git a/test/tv-show.js b/test/tv-show.js new file mode 100644 index 0000000..c802054 --- /dev/null +++ b/test/tv-show.js @@ -0,0 +1,15 @@ +const settings = require("../settings.json") + +const Pavie = require("../pavie") + +const pavie = new Pavie(settings) + +pavie + .signin() + .then(async () => { + const response = await pavie.search(`Big Bang`, {}) + console.log(response) + }) + .catch(err => { + console.error(err) + })