mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
17 KiB
17 KiB
Media
(media)
Overview
API Calls interacting with Plex Media Server Media
Available Operations
- markPlayed - Mark Media Played
- markUnplayed - Mark Media Unplayed
- updatePlayProgress - Update Media Play Progress
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: "<value>",
});
async function run() {
const key = 59398;
const result = await plexAPI.media.markPlayed(key);
// 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<operations.MarkPlayedResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.MarkPlayedResponseBody | 401 | application/json |
| errors.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: "<value>",
});
async function run() {
const key = 59398;
const result = await plexAPI.media.markUnplayed(key);
// 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<operations.MarkUnplayedResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.MarkUnplayedResponseBody | 401 | application/json |
| errors.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: "<value>",
});
async function run() {
const key = "<value>";
const time = 6900.91;
const state = "<value>";
const result = await plexAPI.media.updatePlayProgress(key, time, state);
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
string | ✔️ | the media key |
time |
number | ✔️ | The time, in milliseconds, used to set the media playback progress. |
state |
string | ✔️ | The playback state of the media item. |
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<operations.UpdatePlayProgressResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.UpdatePlayProgressResponseBody | 401 | application/json |
| errors.SDKError | 4xx-5xx | / |