Files
plexgo/docs/sdks/library/README.md

1257 lines
95 KiB
Markdown

# Library
(*Library*)
## Overview
API Calls interacting with Plex Media Server Libraries
### Available Operations
* [GetFileHash](#getfilehash) - Get Hash Value
* [GetRecentlyAddedLibrary](#getrecentlyaddedlibrary) - Get Recently Added
* [GetAllLibraries](#getalllibraries) - Get All Libraries
* [GetLibraryDetails](#getlibrarydetails) - Get Library Details
* [DeleteLibrary](#deletelibrary) - Delete Library Section
* [GetLibraryItems](#getlibraryitems) - Get Library Items
* [GetLibrarySectionsAll](#getlibrarysectionsall) - Get Library section media by tag ALL
* [GetRefreshLibraryMetadata](#getrefreshlibrarymetadata) - Refresh Metadata Of The Library
* [GetSearchLibrary](#getsearchlibrary) - Search Library
* [GetGenresLibrary](#getgenreslibrary) - Get Genres of library media
* [GetCountriesLibrary](#getcountrieslibrary) - Get Countries of library media
* [GetActorsLibrary](#getactorslibrary) - Get Actors of library media
* [GetSearchAllLibraries](#getsearchalllibraries) - Search All Libraries
* [GetMediaMetaData](#getmediametadata) - Get Media Metadata
* [GetMediaArts](#getmediaarts) - Get Media Background Artwork
* [PostMediaArts](#postmediaarts) - Upload Media Background Artwork
* [GetMediaPosters](#getmediaposters) - Get Media Posters
* [PostMediaPoster](#postmediaposter) - Upload Media Poster
* [GetMetadataChildren](#getmetadatachildren) - Get Items Children
* [GetTopWatchedContent](#gettopwatchedcontent) - Get Top Watched Content
## GetFileHash
This resource returns hash values for local files
### Example Usage
<!-- UsageSnippet language="go" operationID="getFileHash" method="get" path="/library/hashes" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetFileHash(ctx, "file://C:\\Image.png&type=13", nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `url_` | *string* | :heavy_check_mark: | This is the path to the local file, must be prefixed by `file://` | file://C:\Image.png&type=13 |
| `type_` | **float64* | :heavy_minus_sign: | Item type | |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetFileHashResponse](../../models/operations/getfilehashresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| --------------------------------- | --------------------------------- | --------------------------------- |
| sdkerrors.GetFileHashBadRequest | 400 | application/json |
| sdkerrors.GetFileHashUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetRecentlyAddedLibrary
This endpoint will return the recently added content.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-recently-added-library" method="get" path="/library/recentlyAdded" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetRecentlyAddedLibrary(ctx, operations.GetRecentlyAddedLibraryRequest{
ContentDirectoryID: plexgo.Int64(2),
PinnedContentDirectoryID: []int64{
3,
5,
7,
13,
12,
1,
6,
14,
2,
10,
16,
17,
},
SectionID: plexgo.Int64(2),
Type: operations.QueryParamTypeTvShow,
IncludeMeta: operations.QueryParamIncludeMetaEnable.ToPointer(),
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `request` | [operations.GetRecentlyAddedLibraryRequest](../../models/operations/getrecentlyaddedlibraryrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetRecentlyAddedLibraryResponse](../../models/operations/getrecentlyaddedlibraryresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| --------------------------------------------- | --------------------------------------------- | --------------------------------------------- |
| sdkerrors.GetRecentlyAddedLibraryBadRequest | 400 | application/json |
| sdkerrors.GetRecentlyAddedLibraryUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetAllLibraries
A library section (commonly referred to as just a library) is a collection of media.
Libraries are typed, and depending on their type provide either a flat or a hierarchical view of the media.
For example, a music library has an artist > albums > tracks structure, whereas a movie library is flat.
Libraries have features beyond just being a collection of media; for starters, they include information about supported types, filters and sorts.
This allows a client to provide a rich interface around the media (e.g. allow sorting movies by release year).
### Example Usage
<!-- UsageSnippet language="go" operationID="get-all-libraries" method="get" path="/library/sections" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetAllLibraries(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description |
| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetAllLibrariesResponse](../../models/operations/getalllibrariesresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------------------------- | ------------------------------------- | ------------------------------------- |
| sdkerrors.GetAllLibrariesBadRequest | 400 | application/json |
| sdkerrors.GetAllLibrariesUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetLibraryDetails
## Library Details Endpoint
This endpoint provides comprehensive details about the library, focusing on organizational aspects rather than the content itself.
The details include:
### Directories
Organized into three categories:
- **Primary Directories**:
- Used in some clients for quick access to media subsets (e.g., "All", "On Deck").
- Most can be replicated via media queries.
- Customizable by users.
- **Secondary Directories**:
- Marked with `secondary="1"`.
- Used in older clients for structured navigation.
- **Special Directories**:
- Includes a "By Folder" entry for filesystem-based browsing.
- Contains an obsolete `search="1"` entry for on-the-fly search dialog creation.
### Types
Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls:
- **Type Object Attributes**:
- `key`: Endpoint for the media list of this type.
- `type`: Metadata type (if standard Plex type).
- `title`: Title for this content type (e.g., "Movies").
- **Filter Objects**:
- Subset of the media query language.
- Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`.
- **Sort Objects**:
- Description of sort fields.
- Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`.
> **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-library-details" method="get" path="/library/sections/{sectionKey}" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetLibraryDetails(ctx, 9518, operations.IncludeDetailsZero.ToPointer())
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `sectionKey` | *int* | :heavy_check_mark: | The unique key of the Plex library. <br/>Note: This is unique in the context of the Plex server.<br/> | 9518 |
| `includeDetails` | [*operations.IncludeDetails](../../models/operations/includedetails.md) | :heavy_minus_sign: | Whether or not to include details for a section (types, filters, and sorts).<br/>Only exists for backwards compatibility, media providers other than the server libraries have it on always.<br/> | |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetLibraryDetailsResponse](../../models/operations/getlibrarydetailsresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| --------------------------------------- | --------------------------------------- | --------------------------------------- |
| sdkerrors.GetLibraryDetailsBadRequest | 400 | application/json |
| sdkerrors.GetLibraryDetailsUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## DeleteLibrary
Delete a library using a specific section id
### Example Usage
<!-- UsageSnippet language="go" operationID="deleteLibrary" method="delete" path="/library/sections/{sectionKey}" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.DeleteLibrary(ctx, 9518)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `sectionKey` | *int* | :heavy_check_mark: | The unique key of the Plex library. <br/>Note: This is unique in the context of the Plex server.<br/> | 9518 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.DeleteLibraryResponse](../../models/operations/deletelibraryresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ----------------------------------- | ----------------------------------- | ----------------------------------- |
| sdkerrors.DeleteLibraryBadRequest | 400 | application/json |
| sdkerrors.DeleteLibraryUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetLibraryItems
Fetches details from a specific section of the library identified by a section key and a tag. The tag parameter accepts the following values:
- `all`: All items in the section.
- `unwatched`: Items that have not been played.
- `newest`: Items that are recently released.
- `recentlyAdded`: Items that are recently added to the library.
- `recentlyViewed`: Items that were recently viewed.
- `onDeck`: Items to continue watching.
- `collection`: Items categorized by collection.
- `edition`: Items categorized by edition.
- `genre`: Items categorized by genre.
- `year`: Items categorized by year of release.
- `decade`: Items categorized by decade.
- `director`: Items categorized by director.
- `actor`: Items categorized by starring actor.
- `country`: Items categorized by country of origin.
- `contentRating`: Items categorized by content rating.
- `rating`: Items categorized by rating.
- `resolution`: Items categorized by resolution.
- `firstCharacter`: Items categorized by the first letter.
- `folder`: Items categorized by folder.
- `albums`: Items categorized by album.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-library-items" method="get" path="/library/sections/{sectionKey}/{tag}" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetLibraryItems(ctx, operations.GetLibraryItemsRequest{
Tag: operations.TagNewest,
IncludeGuids: operations.IncludeGuidsEnable.ToPointer(),
Type: operations.GetLibraryItemsQueryParamTypeTvShow,
SectionKey: 9518,
IncludeMeta: operations.GetLibraryItemsQueryParamIncludeMetaEnable.ToPointer(),
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description |
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `request` | [operations.GetLibraryItemsRequest](../../models/operations/getlibraryitemsrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetLibraryItemsResponse](../../models/operations/getlibraryitemsresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------------------------- | ------------------------------------- | ------------------------------------- |
| sdkerrors.GetLibraryItemsBadRequest | 400 | application/json |
| sdkerrors.GetLibraryItemsUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetLibrarySectionsAll
Retrieves a list of all general media data for this library.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-library-sections-all" method="get" path="/library/sections/{sectionKey}/all" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetLibrarySectionsAll(ctx, operations.GetLibrarySectionsAllRequest{
SectionKey: 9518,
Type: operations.GetLibrarySectionsAllQueryParamTypeTvShow,
IncludeMeta: operations.GetLibrarySectionsAllQueryParamIncludeMetaEnable.ToPointer(),
IncludeGuids: operations.QueryParamIncludeGuidsEnable.ToPointer(),
IncludeAdvanced: operations.IncludeAdvancedEnable.ToPointer(),
IncludeCollections: operations.QueryParamIncludeCollectionsEnable.ToPointer(),
IncludeExternalMedia: operations.QueryParamIncludeExternalMediaEnable.ToPointer(),
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `request` | [operations.GetLibrarySectionsAllRequest](../../models/operations/getlibrarysectionsallrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetLibrarySectionsAllResponse](../../models/operations/getlibrarysectionsallresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- |
| sdkerrors.GetLibrarySectionsAllBadRequest | 400 | application/json |
| sdkerrors.GetLibrarySectionsAllUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetRefreshLibraryMetadata
This endpoint Refreshes all the Metadata of the library.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-refresh-library-metadata" method="get" path="/library/sections/{sectionKey}/refresh" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetRefreshLibraryMetadata(ctx, 9518, operations.ForceZero.ToPointer())
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `sectionKey` | *int* | :heavy_check_mark: | The unique key of the Plex library. <br/>Note: This is unique in the context of the Plex server.<br/> | 9518 |
| `force` | [*operations.Force](../../models/operations/force.md) | :heavy_minus_sign: | Force the refresh even if the library is already being refreshed. | 0 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetRefreshLibraryMetadataResponse](../../models/operations/getrefreshlibrarymetadataresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ----------------------------------------------- | ----------------------------------------------- | ----------------------------------------------- |
| sdkerrors.GetRefreshLibraryMetadataBadRequest | 400 | application/json |
| sdkerrors.GetRefreshLibraryMetadataUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetSearchLibrary
Search for content within a specific section of the library.
### Types
Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls:
- **Type Object Attributes**:
- `type`: Metadata type (if standard Plex type).
- `title`: Title for this content type (e.g., "Movies").
- **Filter Objects**:
- Subset of the media query language.
- Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`.
- **Sort Objects**:
- Description of sort fields.
- Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`.
> **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-search-library" method="get" path="/library/sections/{sectionKey}/search" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetSearchLibrary(ctx, 9518, operations.GetSearchLibraryQueryParamTypeTvShow)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `sectionKey` | *int* | :heavy_check_mark: | The unique key of the Plex library. <br/>Note: This is unique in the context of the Plex server.<br/> | 9518 |
| `type_` | [operations.GetSearchLibraryQueryParamType](../../models/operations/getsearchlibraryqueryparamtype.md) | :heavy_check_mark: | The type of media to retrieve or filter by.<br/>1 = movie<br/>2 = show<br/>3 = season<br/>4 = episode<br/>E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries<br/> | 2 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetSearchLibraryResponse](../../models/operations/getsearchlibraryresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
| sdkerrors.GetSearchLibraryBadRequest | 400 | application/json |
| sdkerrors.GetSearchLibraryUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetGenresLibrary
Retrieves a list of all the genres that are found for the media in this library.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-genres-library" method="get" path="/library/sections/{sectionKey}/genre" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetGenresLibrary(ctx, 9518, operations.GetGenresLibraryQueryParamTypeTvShow)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `sectionKey` | *int* | :heavy_check_mark: | The unique key of the Plex library. <br/>Note: This is unique in the context of the Plex server.<br/> | 9518 |
| `type_` | [operations.GetGenresLibraryQueryParamType](../../models/operations/getgenreslibraryqueryparamtype.md) | :heavy_check_mark: | The type of media to retrieve or filter by.<br/>1 = movie<br/>2 = show<br/>3 = season<br/>4 = episode<br/>E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries<br/> | 2 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetGenresLibraryResponse](../../models/operations/getgenreslibraryresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
| sdkerrors.GetGenresLibraryBadRequest | 400 | application/json |
| sdkerrors.GetGenresLibraryUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetCountriesLibrary
Retrieves a list of all the countries that are found for the media in this library.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-countries-library" method="get" path="/library/sections/{sectionKey}/country" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetCountriesLibrary(ctx, 9518, operations.GetCountriesLibraryQueryParamTypeTvShow)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `sectionKey` | *int* | :heavy_check_mark: | The unique key of the Plex library. <br/>Note: This is unique in the context of the Plex server.<br/> | 9518 |
| `type_` | [operations.GetCountriesLibraryQueryParamType](../../models/operations/getcountrieslibraryqueryparamtype.md) | :heavy_check_mark: | The type of media to retrieve or filter by.<br/>1 = movie<br/>2 = show<br/>3 = season<br/>4 = episode<br/>E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries<br/> | 2 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetCountriesLibraryResponse](../../models/operations/getcountrieslibraryresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- |
| sdkerrors.GetCountriesLibraryBadRequest | 400 | application/json |
| sdkerrors.GetCountriesLibraryUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetActorsLibrary
Retrieves a list of all the actors that are found for the media in this library.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-actors-library" method="get" path="/library/sections/{sectionKey}/actor" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetActorsLibrary(ctx, 9518, operations.GetActorsLibraryQueryParamTypeTvShow)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `sectionKey` | *int* | :heavy_check_mark: | The unique key of the Plex library. <br/>Note: This is unique in the context of the Plex server.<br/> | 9518 |
| `type_` | [operations.GetActorsLibraryQueryParamType](../../models/operations/getactorslibraryqueryparamtype.md) | :heavy_check_mark: | The type of media to retrieve or filter by.<br/>1 = movie<br/>2 = show<br/>3 = season<br/>4 = episode<br/>E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries<br/> | 2 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetActorsLibraryResponse](../../models/operations/getactorslibraryresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
| sdkerrors.GetActorsLibraryBadRequest | 400 | application/json |
| sdkerrors.GetActorsLibraryUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetSearchAllLibraries
Search the provided query across all library sections, or a single section, and return matches as hubs, split up by type.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-search-all-libraries" method="get" path="/library/search" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetSearchAllLibraries(ctx, operations.GetSearchAllLibrariesRequest{
Query: "<value>",
ClientID: "3381b62b-9ab7-4e37-827b-203e9809eb58",
SearchTypes: []operations.SearchTypes{
operations.SearchTypesPeople,
},
IncludeCollections: operations.GetSearchAllLibrariesQueryParamIncludeCollectionsEnable.ToPointer(),
IncludeExternalMedia: operations.GetSearchAllLibrariesQueryParamIncludeExternalMediaEnable.ToPointer(),
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `request` | [operations.GetSearchAllLibrariesRequest](../../models/operations/getsearchalllibrariesrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetSearchAllLibrariesResponse](../../models/operations/getsearchalllibrariesresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- |
| sdkerrors.GetSearchAllLibrariesBadRequest | 400 | application/json |
| sdkerrors.GetSearchAllLibrariesUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetMediaMetaData
This endpoint will return all the (meta)data of one or more library items specified by the ratingKey.
Multiple rating keys can be provided as a comma-separated list (e.g., "21119,21617").
### Example Usage
<!-- UsageSnippet language="go" operationID="get-media-meta-data" method="get" path="/library/metadata/{ratingKey}" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetMediaMetaData(ctx, operations.GetMediaMetaDataRequest{
RatingKey: "21119,21617",
IncludeConcerts: plexgo.Bool(true),
IncludeExtras: plexgo.Bool(true),
IncludeOnDeck: plexgo.Bool(true),
IncludePopularLeaves: plexgo.Bool(true),
IncludePreferences: plexgo.Bool(true),
IncludeReviews: plexgo.Bool(true),
IncludeChapters: plexgo.Bool(true),
IncludeStations: plexgo.Bool(true),
IncludeExternalMedia: plexgo.Bool(true),
AsyncAugmentMetadata: plexgo.Bool(true),
AsyncCheckFiles: plexgo.Bool(true),
AsyncRefreshAnalysis: plexgo.Bool(true),
AsyncRefreshLocalMediaAgent: plexgo.Bool(true),
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description |
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `request` | [operations.GetMediaMetaDataRequest](../../models/operations/getmediametadatarequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetMediaMetaDataResponse](../../models/operations/getmediametadataresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
| sdkerrors.GetMediaMetaDataBadRequest | 400 | application/json |
| sdkerrors.GetMediaMetaDataUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetMediaArts
Returns the background artwork for a library item.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-media-arts" method="get" path="/library/metadata/{ratingKey}/arts" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetMediaArts(ctx, 16099)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `ratingKey` | *int64* | :heavy_check_mark: | the id of the library item to return the artwork of. | 16099 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetMediaArtsResponse](../../models/operations/getmediaartsresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------ | ------------------ | ------------------ |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## PostMediaArts
Uploads an image to use as the background artwork for a library item, either from a local file or a remote URL
### Example Usage
<!-- UsageSnippet language="go" operationID="post-media-arts" method="post" path="/library/metadata/{ratingKey}/arts" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.PostMediaArts(ctx, 2268, plexgo.String("https://api.mediux.pro/assets/fcfdc487-dd07-4993-a0c1-0a3015362e5b"), nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `ratingKey` | *int64* | :heavy_check_mark: | the id of the library item to return the posters of. | 2268 |
| `url_` | **string* | :heavy_minus_sign: | The URL of the image, if uploading a remote image | https://api.mediux.pro/assets/fcfdc487-dd07-4993-a0c1-0a3015362e5b |
| `requestBody` | **any* | :heavy_minus_sign: | The contents of the image, if uploading a local file | |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.PostMediaArtsResponse](../../models/operations/postmediaartsresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------ | ------------------ | ------------------ |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetMediaPosters
Returns the available posters for a library item.
### Example Usage
<!-- UsageSnippet language="go" operationID="get-media-posters" method="get" path="/library/metadata/{ratingKey}/posters" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetMediaPosters(ctx, 16099)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `ratingKey` | *int64* | :heavy_check_mark: | the id of the library item to return the posters of. | 16099 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetMediaPostersResponse](../../models/operations/getmediapostersresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------ | ------------------ | ------------------ |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## PostMediaPoster
Uploads a poster to a library item, either from a local file or a remote URL
### Example Usage
<!-- UsageSnippet language="go" operationID="post-media-poster" method="post" path="/library/metadata/{ratingKey}/posters" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.PostMediaPoster(ctx, 2268, plexgo.String("https://api.mediux.pro/assets/fcfdc487-dd07-4993-a0c1-0a3015362e5b"), nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `ratingKey` | *int64* | :heavy_check_mark: | the id of the library item to return the posters of. | 2268 |
| `url_` | **string* | :heavy_minus_sign: | The URL of the image, if uploading a remote image | https://api.mediux.pro/assets/fcfdc487-dd07-4993-a0c1-0a3015362e5b |
| `requestBody` | **any* | :heavy_minus_sign: | The contents of the image, if uploading a local file | |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.PostMediaPosterResponse](../../models/operations/postmediaposterresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------ | ------------------ | ------------------ |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetMetadataChildren
This endpoint will return the children of of a library item specified with the ratingKey.
### Example Usage
<!-- UsageSnippet language="go" operationID="getMetadataChildren" method="get" path="/library/metadata/{ratingKey}/children" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetMetadataChildren(ctx, 2403.67, plexgo.String("Stream"))
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description |
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. |
| `ratingKey` | *float64* | :heavy_check_mark: | the id of the library item to return the children of. |
| `includeElements` | **string* | :heavy_minus_sign: | Adds additional elements to the response. Supported types are (Stream)<br/> |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetMetadataChildrenResponse](../../models/operations/getmetadatachildrenresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- |
| sdkerrors.GetMetadataChildrenBadRequest | 400 | application/json |
| sdkerrors.GetMetadataChildrenUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
## GetTopWatchedContent
This endpoint will return the top watched content from libraries of a certain type
### Example Usage
<!-- UsageSnippet language="go" operationID="getTopWatchedContent" method="get" path="/library/all/top" -->
```go
package main
import(
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Library.GetTopWatchedContent(ctx, operations.GetTopWatchedContentQueryParamTypeTvShow, operations.GetTopWatchedContentQueryParamIncludeGuidsEnable.ToPointer())
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | |
| `type_` | [operations.GetTopWatchedContentQueryParamType](../../models/operations/gettopwatchedcontentqueryparamtype.md) | :heavy_check_mark: | The type of media to retrieve or filter by.<br/>1 = movie<br/>2 = show<br/>3 = season<br/>4 = episode<br/>E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries<br/> | 2 |
| `includeGuids` | [*operations.GetTopWatchedContentQueryParamIncludeGuids](../../models/operations/gettopwatchedcontentqueryparamincludeguids.md) | :heavy_minus_sign: | Adds the Guid object to the response<br/> | 1 |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | |
### Response
**[*operations.GetTopWatchedContentResponse](../../models/operations/gettopwatchedcontentresponse.md), error**
### Errors
| Error Type | Status Code | Content Type |
| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ |
| sdkerrors.GetTopWatchedContentBadRequest | 400 | application/json |
| sdkerrors.GetTopWatchedContentUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |