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

15 KiB

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

package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.SDKError;
import dev.plexapi.sdk.models.operations.MarkPlayedResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .xPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40")
                .build();

            MarkPlayedResponse res = sdk.media().markPlayed()
                .key(59398d)
                .call();

            // handle response
        } catch (dev.plexapi.sdk.models.errors.MarkPlayedBadRequest e) {
            // handle exception
            throw e;
        } catch (dev.plexapi.sdk.models.errors.MarkPlayedUnauthorized e) {
            // handle exception
            throw e;
        } catch (SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }

    }
}

Parameters

Parameter Type Required Description Example
key double ✔️ The media key to mark as played 59398

Response

MarkPlayedResponse

Errors

Error Object Status Code Content Type
models/errors/MarkPlayedBadRequest 400 application/json
models/errors/MarkPlayedUnauthorized 401 application/json
models/errors/SDKError 4xx-5xx */*

markUnplayed

This will mark the provided media key as Unplayed.

Example Usage

package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.SDKError;
import dev.plexapi.sdk.models.operations.MarkUnplayedResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .xPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40")
                .build();

            MarkUnplayedResponse res = sdk.media().markUnplayed()
                .key(59398d)
                .call();

            // handle response
        } catch (dev.plexapi.sdk.models.errors.MarkUnplayedBadRequest e) {
            // handle exception
            throw e;
        } catch (dev.plexapi.sdk.models.errors.MarkUnplayedUnauthorized e) {
            // handle exception
            throw e;
        } catch (SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }

    }
}

Parameters

Parameter Type Required Description Example
key double ✔️ The media key to mark as Unplayed 59398

Response

MarkUnplayedResponse

Errors

Error Object Status Code Content Type
models/errors/MarkUnplayedBadRequest 400 application/json
models/errors/MarkUnplayedUnauthorized 401 application/json
models/errors/SDKError 4xx-5xx */*

updatePlayProgress

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

Example Usage

package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.SDKError;
import dev.plexapi.sdk.models.operations.UpdatePlayProgressResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .xPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40")
                .build();

            UpdatePlayProgressResponse res = sdk.media().updatePlayProgress()
                .key("<key>")
                .time(90000d)
                .state("played")
                .call();

            // handle response
        } catch (dev.plexapi.sdk.models.errors.UpdatePlayProgressBadRequest e) {
            // handle exception
            throw e;
        } catch (dev.plexapi.sdk.models.errors.UpdatePlayProgressUnauthorized e) {
            // handle exception
            throw e;
        } catch (SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }

    }
}

Parameters

Parameter Type Required Description Example
key String ✔️ the media key
time double ✔️ The time, in milliseconds, used to set the media playback progress. 90000
state String ✔️ The playback state of the media item. played

Response

UpdatePlayProgressResponse

Errors

Error Object Status Code Content Type
models/errors/UpdatePlayProgressBadRequest 400 application/json
models/errors/UpdatePlayProgressUnauthorized 401 application/json
models/errors/SDKError 4xx-5xx */*

getBannerImage

Gets the banner image of the media item

Example Usage

package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.SDKError;
import dev.plexapi.sdk.models.operations.GetBannerImageRequest;
import dev.plexapi.sdk.models.operations.GetBannerImageResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .xPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40")
                .build();

            GetBannerImageRequest req = GetBannerImageRequest.builder()
                .ratingKey(9518L)
                .width(396L)
                .height(396L)
                .minSize(1L)
                .upscale(1L)
                .xPlexToken("CV5xoxjTpFKUzBTShsaf")
                .build();

            GetBannerImageResponse res = sdk.media().getBannerImage()
                .request(req)
                .call();

            if (res.responseStream().isPresent()) {
                // handle response
            }
        } catch (dev.plexapi.sdk.models.errors.GetBannerImageBadRequest e) {
            // handle exception
            throw e;
        } catch (dev.plexapi.sdk.models.errors.GetBannerImageUnauthorized e) {
            // handle exception
            throw e;
        } catch (SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }

    }
}

Parameters

Parameter Type Required Description
request GetBannerImageRequest ✔️ The request object to use for the request.

Response

GetBannerImageResponse

Errors

Error Object Status Code Content Type
models/errors/GetBannerImageBadRequest 400 application/json
models/errors/GetBannerImageUnauthorized 401 application/json
models/errors/SDKError 4xx-5xx */*

getThumbImage

Gets the thumbnail image of the media item

Example Usage

package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.SDKError;
import dev.plexapi.sdk.models.operations.GetThumbImageRequest;
import dev.plexapi.sdk.models.operations.GetThumbImageResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .xPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40")
                .build();

            GetThumbImageRequest req = GetThumbImageRequest.builder()
                .ratingKey(9518L)
                .width(396L)
                .height(396L)
                .minSize(1L)
                .upscale(1L)
                .xPlexToken("CV5xoxjTpFKUzBTShsaf")
                .build();

            GetThumbImageResponse res = sdk.media().getThumbImage()
                .request(req)
                .call();

            if (res.responseStream().isPresent()) {
                // handle response
            }
        } catch (dev.plexapi.sdk.models.errors.GetThumbImageBadRequest e) {
            // handle exception
            throw e;
        } catch (dev.plexapi.sdk.models.errors.GetThumbImageUnauthorized e) {
            // handle exception
            throw e;
        } catch (SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }

    }
}

Parameters

Parameter Type Required Description
request GetThumbImageRequest ✔️ The request object to use for the request.

Response

GetThumbImageResponse

Errors

Error Object Status Code Content Type
models/errors/GetThumbImageBadRequest 400 application/json
models/errors/GetThumbImageUnauthorized 401 application/json
models/errors/SDKError 4xx-5xx */*