(Media)
API Calls interacting with Plex Media Server Media
- MarkPlayed - Mark Media Played
- MarkUnplayed - Mark Media Unplayed
- UpdatePlayProgress - Update Media Play Progress
This will mark the provided media key as Played.
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
}
}
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 |
*operations.MarkPlayedResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.MarkPlayedResponseBody | 401 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
This will mark the provided media key as Unplayed.
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
}
}
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 |
*operations.MarkUnplayedResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.MarkUnplayedResponseBody | 401 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
This API command can be used to update the play progress of a media item.
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
}
}
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 |
*operations.UpdatePlayProgressResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.UpdatePlayProgressResponseBody | 401 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |