Files
plexjs/docs/sdks/media/README.md

18 KiB
Raw Blame History

Media

(media)

Overview

API Calls interacting with Plex Media Server Media

Available Operations

markPlayed

This will mark the provided media key as Played.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";

const plexAPI = new PlexAPI({
  accessToken: "<YOUR_API_KEY_HERE>",
  xPlexClientIdentifier: "Postman",
});

async function run() {
  const result = await plexAPI.media.markPlayed(59398);

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description Example
key number ✔️ The media key to mark as played [object Object]
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<models.MarkPlayedResponse>

Errors

Error Object Status Code Content Type
models.MarkPlayedResponseBody 401 application/json
models.SDKError 4xx-5xx /

markUnplayed

This will mark the provided media key as Unplayed.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";

const plexAPI = new PlexAPI({
  accessToken: "<YOUR_API_KEY_HERE>",
  xPlexClientIdentifier: "Postman",
});

async function run() {
  const result = await plexAPI.media.markUnplayed(59398);

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description Example
key number ✔️ The media key to mark as Unplayed [object Object]
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<models.MarkUnplayedResponse>

Errors

Error Object Status Code Content Type
models.MarkUnplayedResponseBody 401 application/json
models.SDKError 4xx-5xx /

updatePlayProgress

This API command can be used to update the play progress of a media item.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";

const plexAPI = new PlexAPI({
  accessToken: "<YOUR_API_KEY_HERE>",
  xPlexClientIdentifier: "Postman",
});

async function run() {
  const result = await plexAPI.media.updatePlayProgress("<value>", 90000, "played");

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description Example
key string ✔️ the media key
time number ✔️ The time, in milliseconds, used to set the media playback progress. [object Object]
state string ✔️ The playback state of the media item. [object Object]
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<models.UpdatePlayProgressResponse>

Errors

Error Object Status Code Content Type
models.UpdatePlayProgressResponseBody 401 application/json
models.SDKError 4xx-5xx /