35 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
- getBannerImage - Get Banner Image
- getThumbImage - Get Thumb Image
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>",
});
async function run() {
const result = await plexAPI.media.markPlayed(59398);
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { mediaMarkPlayed } from "@lukehagar/plexjs/funcs/mediaMarkPlayed.js";
// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await mediaMarkPlayed(plexAPI, 59398);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("mediaMarkPlayed failed:", res.error);
}
}
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. |
|
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.MarkPlayedResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.MarkPlayedBadRequest | 400 | application/json |
| errors.MarkPlayedUnauthorized | 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>",
});
async function run() {
const result = await plexAPI.media.markUnplayed(59398);
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { mediaMarkUnplayed } from "@lukehagar/plexjs/funcs/mediaMarkUnplayed.js";
// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await mediaMarkUnplayed(plexAPI, 59398);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("mediaMarkUnplayed failed:", res.error);
}
}
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. |
|
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.MarkUnplayedResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.MarkUnplayedBadRequest | 400 | application/json |
| errors.MarkUnplayedUnauthorized | 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>",
});
async function run() {
const result = await plexAPI.media.updatePlayProgress("<key>", 90000, "played");
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { mediaUpdatePlayProgress } from "@lukehagar/plexjs/funcs/mediaUpdatePlayProgress.js";
// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await mediaUpdatePlayProgress(plexAPI, "<key>", 90000, "played");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("mediaUpdatePlayProgress failed:", res.error);
}
}
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. |
|
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.UpdatePlayProgressResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.UpdatePlayProgressBadRequest | 400 | application/json |
| errors.UpdatePlayProgressUnauthorized | 401 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
getBannerImage
Gets the banner image of the media item
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await plexAPI.media.getBannerImage({
ratingKey: 9518,
width: 396,
height: 396,
minSize: 1,
upscale: 1,
xPlexToken: "CV5xoxjTpFKUzBTShsaf",
});
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { mediaGetBannerImage } from "@lukehagar/plexjs/funcs/mediaGetBannerImage.js";
// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await mediaGetBannerImage(plexAPI, {
ratingKey: 9518,
width: 396,
height: 396,
minSize: 1,
upscale: 1,
xPlexToken: "CV5xoxjTpFKUzBTShsaf",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("mediaGetBannerImage failed:", res.error);
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetBannerImageRequest | ✔️ | The request object to use for the request. |
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. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.GetBannerImageResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.GetBannerImageBadRequest | 400 | application/json |
| errors.GetBannerImageUnauthorized | 401 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
getThumbImage
Gets the thumbnail image of the media item
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await plexAPI.media.getThumbImage({
ratingKey: 9518,
width: 396,
height: 396,
minSize: 1,
upscale: 1,
xPlexToken: "CV5xoxjTpFKUzBTShsaf",
});
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { mediaGetThumbImage } from "@lukehagar/plexjs/funcs/mediaGetThumbImage.js";
// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await mediaGetThumbImage(plexAPI, {
ratingKey: 9518,
width: 396,
height: 396,
minSize: 1,
upscale: 1,
xPlexToken: "CV5xoxjTpFKUzBTShsaf",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("mediaGetThumbImage failed:", res.error);
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetThumbImageRequest | ✔️ | The request object to use for the request. |
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. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.GetThumbImageResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.GetThumbImageBadRequest | 400 | application/json |
| errors.GetThumbImageUnauthorized | 401 | application/json |
| errors.SDKError | 4XX, 5XX | */* |