Skip to content

Latest commit

 

History

History
173 lines (126 loc) · 8.12 KB

README.md

File metadata and controls

173 lines (126 loc) · 8.12 KB

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/models/components"
	"github.com/LukeHagar/plexgo"
	"context"
	"log"
)

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

    var key float64 = 59398
    
    ctx := context.Background()
    res, err := s.Media.MarkPlayed(ctx, key)
    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

Response

*operations.MarkPlayedResponse, error

Error Object Status Code Content Type
sdkerrors.MarkPlayedResponseBody 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/models/components"
	"github.com/LukeHagar/plexgo"
	"context"
	"log"
)

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

    var key float64 = 59398
    
    ctx := context.Background()
    res, err := s.Media.MarkUnplayed(ctx, key)
    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

Response

*operations.MarkUnplayedResponse, error

Error Object Status Code Content Type
sdkerrors.MarkUnplayedResponseBody 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/models/components"
	"github.com/LukeHagar/plexgo"
	"context"
	"log"
)

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

    var key string = "<value>"

    var time float64 = 90000

    var state string = "played"
    
    ctx := context.Background()
    res, err := s.Media.UpdatePlayProgress(ctx, key, time, state)
    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

Response

*operations.UpdatePlayProgressResponse, error

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