Files
plexjava/docs/sdks/media/README.md
2024-07-01 16:03:10 +00:00

9.4 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 java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import lukehagar.plexapi.plexapi.PlexAPI;
import lukehagar.plexapi.plexapi.models.operations.*;
import lukehagar.plexapi.plexapi.models.shared.*;
import lukehagar.plexapi.plexapi.models.shared.Security;
import lukehagar.plexapi.plexapi.utils.EventStream;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

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

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

            // handle response
        } catch (lukehagar.plexapi.plexapi.models.errors.MarkPlayedResponseBody e) {
            // handle exception
            throw e;
        } catch (lukehagar.plexapi.plexapi.models.errors.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

lukehagar.plexapi.plexapi.models.operations.MarkPlayedResponse

Errors

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

markUnplayed

This will mark the provided media key as Unplayed.

Example Usage

package hello.world;

import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import lukehagar.plexapi.plexapi.PlexAPI;
import lukehagar.plexapi.plexapi.models.operations.*;
import lukehagar.plexapi.plexapi.models.shared.*;
import lukehagar.plexapi.plexapi.models.shared.Security;
import lukehagar.plexapi.plexapi.utils.EventStream;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

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

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

            // handle response
        } catch (lukehagar.plexapi.plexapi.models.errors.MarkUnplayedResponseBody e) {
            // handle exception
            throw e;
        } catch (lukehagar.plexapi.plexapi.models.errors.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

lukehagar.plexapi.plexapi.models.operations.MarkUnplayedResponse

Errors

Error Object Status Code Content Type
models/errors/MarkUnplayedResponseBody 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 java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import lukehagar.plexapi.plexapi.PlexAPI;
import lukehagar.plexapi.plexapi.models.operations.*;
import lukehagar.plexapi.plexapi.models.shared.*;
import lukehagar.plexapi.plexapi.models.shared.Security;
import lukehagar.plexapi.plexapi.utils.EventStream;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

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

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

            // handle response
        } catch (lukehagar.plexapi.plexapi.models.errors.UpdatePlayProgressResponseBody e) {
            // handle exception
            throw e;
        } catch (lukehagar.plexapi.plexapi.models.errors.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

lukehagar.plexapi.plexapi.models.operations.UpdatePlayProgressResponse

Errors

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