From ea62a9dc5bbc4f098c2dcc47236292a2d87d4245 Mon Sep 17 00:00:00 2001 From: Wifsimster Date: Sun, 11 Aug 2019 12:19:05 +0200 Subject: [PATCH] Add history method --- README.md | 26 ++++++++++++++++++-------- package.json | 4 +++- pavie.js | 12 ++++++++++++ test/history.js | 15 +++++++++++++++ 4 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 test/history.js diff --git a/README.md b/README.md index a7aea06..17d9be4 100644 --- a/README.md +++ b/README.md @@ -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` ` | ` Identifiant #### getPlaylistFiles([ratingKey]) -Get playlist video files +Get playlist video files. - `ratingKey` ` | ` Identifiant #### addPlaylist([data]) -Add new playlist +Add new playlist. - `data` `` - `uri` `` Path to a list of video files, ie : `server://2c59cf8256eccd8629081638e98e27bf8349c3e7/com.plexapp.plugins.library/library/metadata/26082` @@ -165,7 +165,7 @@ Add new playlist #### updatePlaylist([ratingKey], [data]) -Update existing playlist +Update existing playlist. - `ratingKey` ` | ` Identifiant - `data` `` @@ -174,13 +174,23 @@ Update existing playlist #### updatePlaylistFiles([ratingKey], [uri]) -Add files to an existing playlist +Add files to an existing playlist. - `ratingKey` ` | ` Identifiant - `uri` `` 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` ` | ` Identifiant + +### History + +#### getHistory(options) + +Get the history of a TV Shows. + +- `options` `` + - `metadataItemID` `` Identifiant + - `sort` `` Order by, default : `viewed:desc` diff --git a/package.json b/package.json index 15990e3..074336d 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,9 @@ "movie", "restfull", "node.js", - "tv shows" + "tv shows", + "episode", + "pms" ], "homepage": "https://github.com/Wifsimster/pavie#readme", "dependencies": { diff --git a/pavie.js b/pavie.js index 5657819..626bcf6 100644 --- a/pavie.js +++ b/pavie.js @@ -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 + } + } } diff --git a/test/history.js b/test/history.js new file mode 100644 index 0000000..91a89db --- /dev/null +++ b/test/history.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.getHistory() + console.log(response) + }) + .catch(err => { + console.error(err) + })