diff --git a/README.md b/README.md index 33ddaf7..89c1510 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,32 @@ Global search of media. - `sectionId` `` - `limit` ``, ie: `30` +### Tv Shows + +#### getTvShows([options]) + +Return tv shows. + +- `options` `` + - `unwatchedLeaves` ``, default: `0` + - `sort` ``, ie: `rating:desc` + +#### getSeasons([options]) + +Return tv shows seasons. + +- `options` `` + - `includeCollections` ``, default: `1` + - `sort` ``, ie: `rating:desc` + +#### getEpisodes([options]) + +Return tv shows episodes. + +- `options` `` + - `includeCollections` ``, default: `1` + - `sort` ``, ie: `rating:desc` + ### Synchronize #### getSynchronize() diff --git a/pavie.js b/pavie.js index 3e46ccd..d10eaea 100644 --- a/pavie.js +++ b/pavie.js @@ -333,4 +333,31 @@ module.exports = class { return response.data.MediaContainer } } + + async getTvShows(options = {}) { + options = Object.assign({ type: 2, unwatchedLeaves: 0, sort: null }, options) + const response = await this.instance.get(`/library/sections/2/all?${querystring.stringify(options)}`) + + if (response.status < 400) { + return response.data.MediaContainer + } + } + + async getSeasons(options = {}) { + options = Object.assign({ type: 3, includeCollections: 1, sort: null }, options) + const response = await this.instance.get(`/library/sections/2/all?${querystring.stringify(options)}`) + + if (response.status < 400) { + return response.data.MediaContainer + } + } + + async getEpisodes(options = {}) { + options = Object.assign({ type: 4, includeCollections: 1, sort: null }, options) + const response = await this.instance.get(`/library/sections/2/all?${querystring.stringify(options)}`) + + if (response.status < 400) { + return response.data.MediaContainer + } + } } diff --git a/test/tv-show.js b/test/tv-show.js index c802054..95abc7f 100644 --- a/test/tv-show.js +++ b/test/tv-show.js @@ -7,7 +7,7 @@ const pavie = new Pavie(settings) pavie .signin() .then(async () => { - const response = await pavie.search(`Big Bang`, {}) + const response = await pavie.getTvShows({}) console.log(response) }) .catch(err => {