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

14 KiB
Raw Blame History

Media

(media)

Overview

API Calls interacting with Plex Media Server Media

Available Operations

mark_played

This will mark the provided media key as Played.

Example Usage

from plex_api_client import PlexAPI

s = PlexAPI(
    access_token="<YOUR_API_KEY_HERE>",
    client_id="3381b62b-9ab7-4e37-827b-203e9809eb58",
    client_name="Plex for Roku",
    client_version="2.4.1",
    platform="Roku",
    device_nickname="Roku 3",
)

res = s.media.mark_played(key=59398)

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description Example
key float ✔️ The media key to mark as played 59398
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.MarkPlayedResponse

Errors

Error Type Status Code Content Type
errors.MarkPlayedBadRequest 400 application/json
errors.MarkPlayedUnauthorized 401 application/json
errors.SDKError 4XX, 5XX */*

mark_unplayed

This will mark the provided media key as Unplayed.

Example Usage

from plex_api_client import PlexAPI

s = PlexAPI(
    access_token="<YOUR_API_KEY_HERE>",
    client_id="3381b62b-9ab7-4e37-827b-203e9809eb58",
    client_name="Plex for Roku",
    client_version="2.4.1",
    platform="Roku",
    device_nickname="Roku 3",
)

res = s.media.mark_unplayed(key=59398)

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description Example
key float ✔️ The media key to mark as Unplayed 59398
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.MarkUnplayedResponse

Errors

Error Type Status Code Content Type
errors.MarkUnplayedBadRequest 400 application/json
errors.MarkUnplayedUnauthorized 401 application/json
errors.SDKError 4XX, 5XX */*

update_play_progress

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

Example Usage

from plex_api_client import PlexAPI

s = PlexAPI(
    access_token="<YOUR_API_KEY_HERE>",
    client_id="3381b62b-9ab7-4e37-827b-203e9809eb58",
    client_name="Plex for Roku",
    client_version="2.4.1",
    platform="Roku",
    device_nickname="Roku 3",
)

res = s.media.update_play_progress(key="<key>", time=90000, state="played")

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description Example
key str ✔️ the media key
time float ✔️ The time, in milliseconds, used to set the media playback progress. 90000
state str ✔️ The playback state of the media item. played
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.UpdatePlayProgressResponse

Errors

Error Type Status Code Content Type
errors.UpdatePlayProgressBadRequest 400 application/json
errors.UpdatePlayProgressUnauthorized 401 application/json
errors.SDKError 4XX, 5XX */*

get_banner_image

Gets the banner image of the media item

Example Usage

from plex_api_client import PlexAPI

s = PlexAPI(
    access_token="<YOUR_API_KEY_HERE>",
    client_id="3381b62b-9ab7-4e37-827b-203e9809eb58",
    client_name="Plex for Roku",
    client_version="2.4.1",
    platform="Roku",
    device_nickname="Roku 3",
)

res = s.media.get_banner_image(request={
    "rating_key": 9518,
    "width": 396,
    "height": 396,
    "min_size": 1,
    "upscale": 1,
    "x_plex_token": "CV5xoxjTpFKUzBTShsaf",
})

if res.response_stream is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
request operations.GetBannerImageRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetBannerImageResponse

Errors

Error Type Status Code Content Type
errors.GetBannerImageBadRequest 400 application/json
errors.GetBannerImageUnauthorized 401 application/json
errors.SDKError 4XX, 5XX */*

get_thumb_image

Gets the thumbnail image of the media item

Example Usage

from plex_api_client import PlexAPI

s = PlexAPI(
    access_token="<YOUR_API_KEY_HERE>",
    client_id="3381b62b-9ab7-4e37-827b-203e9809eb58",
    client_name="Plex for Roku",
    client_version="2.4.1",
    platform="Roku",
    device_nickname="Roku 3",
)

res = s.media.get_thumb_image(request={
    "rating_key": 9518,
    "width": 396,
    "height": 396,
    "min_size": 1,
    "upscale": 1,
    "x_plex_token": "CV5xoxjTpFKUzBTShsaf",
})

if res.response_stream is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
request operations.GetThumbImageRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetThumbImageResponse

Errors

Error Type Status Code Content Type
errors.GetThumbImageBadRequest 400 application/json
errors.GetThumbImageUnauthorized 401 application/json
errors.SDKError 4XX, 5XX */*