Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Wifsimster committed Aug 11, 2019
1 parent 30ec22d commit 85e7249
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 132 deletions.
98 changes: 31 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -11,18 +11,14 @@ 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)

[Playlists](https://github.com/Wifsimster/pavie#playlists)

[History](https://github.com/Wifsimster/pavie#history)

[Metadata](https://github.com/Wifsimster/pavie#metadata)

[Images](https://github.com/Wifsimster/pavie#images)

## Install
Expand Down Expand Up @@ -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 !
Expand Down Expand Up @@ -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` `<number>` 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` `<number>` Identifiant
- `options` `<object>`
- `excludeAllLeaves` `<number>`, default: `1`

### getRelated([id], [options])

Return a list of related media.

### Directories
- `id` `<number>` Identifiant
- `options` `<object>`
- `excludeFields` `<string>`, default: `summary`
- `includeExternalMetadata` `<number>`, default: `1`
- `asyncAugmentMetadata` `<number>`, 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` `<number>` 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` `<string>`
- `options` `<object>`
- `includeCollections` `<number>`, default: `1`
- `sectionId` `<number>`
- `limit` `<number>`, ie: `30`

### Synchronize

Expand Down Expand Up @@ -195,39 +192,6 @@ Get the history of a TV Shows.
- `metadataItemID` `<number>` Identifiant
- `sort` `<string>` Order by, default : `viewed:desc`

### Metadata

### getMetadata([id])

Return all info about a media.

- `id` `<number>` Identifiant

### getMetadataChildren([id], [options])

Return all children metadata for a specified media.
ie: Returnn seasons metadata for a specified Tv Show.

- `id` `<number>` Identifiant
- `options` `<object>`
- `excludeAllLeaves` `<number>`, default: `1`

### getRelated([id], [options])

Return a list of related media.

- `id` `<number>` Identifiant
- `options` `<object>`
- `excludeFields` `<string>`, default: `summary`
- `includeExternalMetadata` `<number>`, default: `1`
- `asyncAugmentMetadata` `<number>`, default: `1`

### getSimilar([id])

Return a list of similar media.

- `id` `<number>` Identifiant

### Images

#### getImage([url], [options])
Expand Down
77 changes: 12 additions & 65 deletions pavie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
}
}
}
15 changes: 15 additions & 0 deletions test/tv-show.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.search(`Big Bang`, {})
console.log(response)
})
.catch(err => {
console.error(err)
})

0 comments on commit 85e7249

Please sign in to comment.