Skip to content

Commit

Permalink
Add tv shows methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Wifsimster committed Aug 11, 2019
1 parent 85e7249 commit 70039a1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ Global search of media.
- `sectionId` `<number>`
- `limit` `<number>`, ie: `30`

### Tv Shows

#### getTvShows([options])

Return tv shows.

- `options` `<object>`
- `unwatchedLeaves` `<number>`, default: `0`
- `sort` `<string>`, ie: `rating:desc`

#### getSeasons([options])

Return tv shows seasons.

- `options` `<object>`
- `includeCollections` `<number>`, default: `1`
- `sort` `<string>`, ie: `rating:desc`

#### getEpisodes([options])

Return tv shows episodes.

- `options` `<object>`
- `includeCollections` `<number>`, default: `1`
- `sort` `<string>`, ie: `rating:desc`

### Synchronize

#### getSynchronize()
Expand Down
27 changes: 27 additions & 0 deletions pavie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
2 changes: 1 addition & 1 deletion test/tv-show.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 70039a1

Please sign in to comment.