Skip to content

Commit

Permalink
Add history method
Browse files Browse the repository at this point in the history
  • Loading branch information
Wifsimster committed Aug 11, 2019
1 parent ef3ad9f commit ea62a9d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,29 @@ Synchronize Plex and Trakt.tv.

#### getHubs([action = 'continueWatching'])

Hubs actions [continueWatching, onDeck]
Hubs actions [continueWatching, onDeck].

### Playlists

#### getPlaylists()

Get all playlists
Get all playlists.

#### getPlaylist([ratingKey])

Get playlist basic info
Get playlist basic info.

- `ratingKey` `<string> | <number>` Identifiant

#### getPlaylistFiles([ratingKey])

Get playlist video files
Get playlist video files.

- `ratingKey` `<string> | <number>` Identifiant

#### addPlaylist([data])

Add new playlist
Add new playlist.

- `data` `<object>`
- `uri` `<string>` Path to a list of video files, ie : `server://2c59cf8256eccd8629081638e98e27bf8349c3e7/com.plexapp.plugins.library/library/metadata/26082`
Expand All @@ -165,7 +165,7 @@ Add new playlist

#### updatePlaylist([ratingKey], [data])

Update existing playlist
Update existing playlist.

- `ratingKey` `<string> | <number>` Identifiant
- `data` `<object>`
Expand All @@ -174,13 +174,23 @@ Update existing playlist

#### updatePlaylistFiles([ratingKey], [uri])

Add files to an existing playlist
Add files to an existing playlist.

- `ratingKey` `<string> | <number>` Identifiant
- `uri` `<string>` Path to a list of video files, ie: `server://2c59cf8256eccd8629081638e98e27bf8349c3e7/com.plexapp.plugins.library/library/metadata/26082`

#### removePlaylist([ratingKey])

Remove existing playlist
Remove existing playlist.

- `ratingKey` `<string> | <number>` Identifiant

### History

#### getHistory(options)

Get the history of a TV Shows.

- `options` `<object>`
- `metadataItemID` `<number>` Identifiant
- `sort` `<string>` Order by, default : `viewed:desc`
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"movie",
"restfull",
"node.js",
"tv shows"
"tv shows",
"episode",
"pms"
],
"homepage": "https://github.com/Wifsimster/pavie#readme",
"dependencies": {
Expand Down
12 changes: 12 additions & 0 deletions pavie.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,16 @@ module.exports = class {
return response.data
}
}

/**
* Get history
*/
async getHistory(filters = {}) {
filters = Object.assign({ sort: "viewedAt:desc" }, filters)
const response = await this.instance.get(`/status/sessions/history/all?${querystring.stringify(filters)}`)

if (response.status < 400) {
return response.data.MediaContainer
}
}
}
15 changes: 15 additions & 0 deletions test/history.js
Original file line number Diff line number Diff line change
@@ -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.getHistory()
console.log(response)
})
.catch(err => {
console.error(err)
})

0 comments on commit ea62a9d

Please sign in to comment.