Files
plexgo/docs/sdks/media/README.md
2024-09-09 18:15:22 +00:00

16 KiB
Raw Blame History

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 main

import(
	"github.com/LukeHagar/plexgo"
	"context"
	"log"
)

func main() {
    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
        plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
    )

    ctx := context.Background()
    res, err := s.Media.MarkPlayed(ctx, 59398)
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
key float64 ✔️ The media key to mark as played 59398
opts []operations.Option The options for this request.

Response

*operations.MarkPlayedResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.MarkPlayedResponseBody 400 application/json
sdkerrors.MarkPlayedMediaResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /

MarkUnplayed

This will mark the provided media key as Unplayed.

Example Usage

package main

import(
	"github.com/LukeHagar/plexgo"
	"context"
	"log"
)

func main() {
    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
        plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
    )

    ctx := context.Background()
    res, err := s.Media.MarkUnplayed(ctx, 59398)
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
key float64 ✔️ The media key to mark as Unplayed 59398
opts []operations.Option The options for this request.

Response

*operations.MarkUnplayedResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.MarkUnplayedResponseBody 400 application/json
sdkerrors.MarkUnplayedMediaResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /

UpdatePlayProgress

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

Example Usage

package main

import(
	"github.com/LukeHagar/plexgo"
	"context"
	"log"
)

func main() {
    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
        plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
    )

    ctx := context.Background()
    res, err := s.Media.UpdatePlayProgress(ctx, "<key>", 90000, "played")
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
key string ✔️ the media key
time float64 ✔️ The time, in milliseconds, used to set the media playback progress. 90000
state string ✔️ The playback state of the media item. played
opts []operations.Option The options for this request.

Response

*operations.UpdatePlayProgressResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.UpdatePlayProgressResponseBody 400 application/json
sdkerrors.UpdatePlayProgressMediaResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /

GetBannerImage

Gets the banner image of the media item

Example Usage

package main

import(
	"github.com/LukeHagar/plexgo"
	"context"
	"github.com/LukeHagar/plexgo/models/operations"
	"log"
)

func main() {
    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
        plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
    )

    ctx := context.Background()
    res, err := s.Media.GetBannerImage(ctx, operations.GetBannerImageRequest{
        RatingKey: 9518,
        Width: 396,
        Height: 396,
        MinSize: 1,
        Upscale: 1,
        XPlexToken: "CV5xoxjTpFKUzBTShsaf",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ResponseStream != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetBannerImageRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.GetBannerImageResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.GetBannerImageResponseBody 400 application/json
sdkerrors.GetBannerImageMediaResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /

GetThumbImage

Gets the thumbnail image of the media item

Example Usage

package main

import(
	"github.com/LukeHagar/plexgo"
	"context"
	"github.com/LukeHagar/plexgo/models/operations"
	"log"
)

func main() {
    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
        plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
    )

    ctx := context.Background()
    res, err := s.Media.GetThumbImage(ctx, operations.GetThumbImageRequest{
        RatingKey: 9518,
        Width: 396,
        Height: 396,
        MinSize: 1,
        Upscale: 1,
        XPlexToken: "CV5xoxjTpFKUzBTShsaf",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ResponseStream != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetThumbImageRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.GetThumbImageResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.GetThumbImageResponseBody 400 application/json
sdkerrors.GetThumbImageMediaResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /