Files
plexjava/src/main/java/dev/plexapi/sdk/Playlists.java

444 lines
19 KiB
Java

/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
package dev.plexapi.sdk;
import static dev.plexapi.sdk.operations.Operations.RequestOperation;
import dev.plexapi.sdk.models.operations.AddPlaylistContentsRequest;
import dev.plexapi.sdk.models.operations.AddPlaylistContentsRequestBuilder;
import dev.plexapi.sdk.models.operations.AddPlaylistContentsResponse;
import dev.plexapi.sdk.models.operations.ClearPlaylistContentsRequest;
import dev.plexapi.sdk.models.operations.ClearPlaylistContentsRequestBuilder;
import dev.plexapi.sdk.models.operations.ClearPlaylistContentsResponse;
import dev.plexapi.sdk.models.operations.CreatePlaylistRequest;
import dev.plexapi.sdk.models.operations.CreatePlaylistRequestBuilder;
import dev.plexapi.sdk.models.operations.CreatePlaylistResponse;
import dev.plexapi.sdk.models.operations.DeletePlaylistRequest;
import dev.plexapi.sdk.models.operations.DeletePlaylistRequestBuilder;
import dev.plexapi.sdk.models.operations.DeletePlaylistResponse;
import dev.plexapi.sdk.models.operations.GetPlaylistContentsQueryParamType;
import dev.plexapi.sdk.models.operations.GetPlaylistContentsRequest;
import dev.plexapi.sdk.models.operations.GetPlaylistContentsRequestBuilder;
import dev.plexapi.sdk.models.operations.GetPlaylistContentsResponse;
import dev.plexapi.sdk.models.operations.GetPlaylistRequest;
import dev.plexapi.sdk.models.operations.GetPlaylistRequestBuilder;
import dev.plexapi.sdk.models.operations.GetPlaylistResponse;
import dev.plexapi.sdk.models.operations.GetPlaylistsRequest;
import dev.plexapi.sdk.models.operations.GetPlaylistsRequestBuilder;
import dev.plexapi.sdk.models.operations.GetPlaylistsResponse;
import dev.plexapi.sdk.models.operations.PlaylistType;
import dev.plexapi.sdk.models.operations.QueryParamForce;
import dev.plexapi.sdk.models.operations.QueryParamSmart;
import dev.plexapi.sdk.models.operations.UpdatePlaylistRequest;
import dev.plexapi.sdk.models.operations.UpdatePlaylistRequestBuilder;
import dev.plexapi.sdk.models.operations.UpdatePlaylistResponse;
import dev.plexapi.sdk.models.operations.UploadPlaylistRequest;
import dev.plexapi.sdk.models.operations.UploadPlaylistRequestBuilder;
import dev.plexapi.sdk.models.operations.UploadPlaylistResponse;
import dev.plexapi.sdk.operations.AddPlaylistContents;
import dev.plexapi.sdk.operations.ClearPlaylistContents;
import dev.plexapi.sdk.operations.CreatePlaylist;
import dev.plexapi.sdk.operations.DeletePlaylist;
import dev.plexapi.sdk.operations.GetPlaylist;
import dev.plexapi.sdk.operations.GetPlaylistContents;
import dev.plexapi.sdk.operations.GetPlaylists;
import dev.plexapi.sdk.operations.UpdatePlaylist;
import dev.plexapi.sdk.operations.UploadPlaylist;
import java.lang.Double;
import java.lang.Exception;
import java.lang.String;
import java.util.Optional;
/**
* Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as "all albums from 2017").
* They can be organized in (optionally nesting) folders.
* Retrieving a playlist, or its items, will trigger a refresh of its metadata.
* This may cause the duration and number of items to change.
*/
public class Playlists {
private final SDKConfiguration sdkConfiguration;
private final AsyncPlaylists asyncSDK;
Playlists(SDKConfiguration sdkConfiguration) {
this.sdkConfiguration = sdkConfiguration;
this.asyncSDK = new AsyncPlaylists(this, sdkConfiguration);
}
/**
* Switches to the async SDK.
*
* @return The async SDK
*/
public AsyncPlaylists async() {
return asyncSDK;
}
/**
* Create a Playlist
*
* <p>Create a new playlist. By default the playlist is blank. To create a playlist along with a first item, pass:
* - `uri` - The content URI for what we're playing (e.g. `server://1234/com.plexapp.plugins.library/library/metadata/1`).
* - `playQueueID` - To create a playlist from an existing play queue.
*
* @return The call builder
*/
public CreatePlaylistRequestBuilder createPlaylist() {
return new CreatePlaylistRequestBuilder(sdkConfiguration);
}
/**
* Create a Playlist
*
* <p>Create a new playlist. By default the playlist is blank. To create a playlist along with a first item, pass:
* - `uri` - The content URI for what we're playing (e.g. `server://1234/com.plexapp.plugins.library/library/metadata/1`).
* - `playQueueID` - To create a playlist from an existing play queue.
*
* @param request The request object containing all the parameters for the API call.
* @return The response from the API call
* @throws Exception if the API call fails
*/
public CreatePlaylistResponse createPlaylist(CreatePlaylistRequest request) throws Exception {
RequestOperation<CreatePlaylistRequest, CreatePlaylistResponse> operation
= new CreatePlaylist.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
/**
* Get All Playlists
*
* <p>Get All Playlists given the specified filters.
*
* @return The call builder
*/
public GetPlaylistsRequestBuilder getPlaylists() {
return new GetPlaylistsRequestBuilder(sdkConfiguration);
}
/**
* Get All Playlists
*
* <p>Get All Playlists given the specified filters.
*
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetPlaylistsResponse getPlaylistsDirect() throws Exception {
return getPlaylists(Optional.empty(), Optional.empty());
}
/**
* Get All Playlists
*
* <p>Get All Playlists given the specified filters.
*
* @param playlistType limit to a type of playlist.
* @param smart type of playlists to return (default is all).
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetPlaylistsResponse getPlaylists(Optional<? extends PlaylistType> playlistType, Optional<? extends QueryParamSmart> smart) throws Exception {
GetPlaylistsRequest request =
GetPlaylistsRequest
.builder()
.playlistType(playlistType)
.smart(smart)
.build();
RequestOperation<GetPlaylistsRequest, GetPlaylistsResponse> operation
= new GetPlaylists.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
/**
* Retrieve Playlist
*
* <p>Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
* Smart playlist details contain the `content` attribute. This is the content URI for the generator. This can then be parsed by a client to provide smart playlist editing.
*
* @return The call builder
*/
public GetPlaylistRequestBuilder getPlaylist() {
return new GetPlaylistRequestBuilder(sdkConfiguration);
}
/**
* Retrieve Playlist
*
* <p>Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
* Smart playlist details contain the `content` attribute. This is the content URI for the generator. This can then be parsed by a client to provide smart playlist editing.
*
* @param playlistID the ID of the playlist
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetPlaylistResponse getPlaylist(double playlistID) throws Exception {
GetPlaylistRequest request =
GetPlaylistRequest
.builder()
.playlistID(playlistID)
.build();
RequestOperation<GetPlaylistRequest, GetPlaylistResponse> operation
= new GetPlaylist.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
/**
* Deletes a Playlist
*
* <p>This endpoint will delete a playlist
*
* @return The call builder
*/
public DeletePlaylistRequestBuilder deletePlaylist() {
return new DeletePlaylistRequestBuilder(sdkConfiguration);
}
/**
* Deletes a Playlist
*
* <p>This endpoint will delete a playlist
*
* @param playlistID the ID of the playlist
* @return The response from the API call
* @throws Exception if the API call fails
*/
public DeletePlaylistResponse deletePlaylist(double playlistID) throws Exception {
DeletePlaylistRequest request =
DeletePlaylistRequest
.builder()
.playlistID(playlistID)
.build();
RequestOperation<DeletePlaylistRequest, DeletePlaylistResponse> operation
= new DeletePlaylist.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
/**
* Update a Playlist
*
* <p>From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
*
* @return The call builder
*/
public UpdatePlaylistRequestBuilder updatePlaylist() {
return new UpdatePlaylistRequestBuilder(sdkConfiguration);
}
/**
* Update a Playlist
*
* <p>From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
*
* @param playlistID the ID of the playlist
* @return The response from the API call
* @throws Exception if the API call fails
*/
public UpdatePlaylistResponse updatePlaylist(double playlistID) throws Exception {
return updatePlaylist(playlistID, Optional.empty(), Optional.empty());
}
/**
* Update a Playlist
*
* <p>From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
*
* @param playlistID the ID of the playlist
* @param title name of the playlist
* @param summary summary description of the playlist
* @return The response from the API call
* @throws Exception if the API call fails
*/
public UpdatePlaylistResponse updatePlaylist(
double playlistID, Optional<String> title,
Optional<String> summary) throws Exception {
UpdatePlaylistRequest request =
UpdatePlaylistRequest
.builder()
.playlistID(playlistID)
.title(title)
.summary(summary)
.build();
RequestOperation<UpdatePlaylistRequest, UpdatePlaylistResponse> operation
= new UpdatePlaylist.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
/**
* Retrieve Playlist Contents
*
* <p>Gets the contents of a playlist. Should be paged by clients via standard mechanisms.
* By default leaves are returned (e.g. episodes, movies). In order to return other types you can use the `type` parameter.
* For example, you could use this to display a list of recently added albums vis a smart playlist.
* Note that for dumb playlists, items have a `playlistItemID` attribute which is used for deleting or moving items.
*
* @return The call builder
*/
public GetPlaylistContentsRequestBuilder getPlaylistContents() {
return new GetPlaylistContentsRequestBuilder(sdkConfiguration);
}
/**
* Retrieve Playlist Contents
*
* <p>Gets the contents of a playlist. Should be paged by clients via standard mechanisms.
* By default leaves are returned (e.g. episodes, movies). In order to return other types you can use the `type` parameter.
* For example, you could use this to display a list of recently added albums vis a smart playlist.
* Note that for dumb playlists, items have a `playlistItemID` attribute which is used for deleting or moving items.
*
* @param playlistID the ID of the playlist
* @param type The type of media to retrieve or filter by.
* 1 = movie
* 2 = show
* 3 = season
* 4 = episode
* E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
*
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetPlaylistContentsResponse getPlaylistContents(double playlistID, GetPlaylistContentsQueryParamType type) throws Exception {
GetPlaylistContentsRequest request =
GetPlaylistContentsRequest
.builder()
.playlistID(playlistID)
.type(type)
.build();
RequestOperation<GetPlaylistContentsRequest, GetPlaylistContentsResponse> operation
= new GetPlaylistContents.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
/**
* Delete Playlist Contents
*
* <p>Clears a playlist, only works with dumb playlists. Returns the playlist.
*
* @return The call builder
*/
public ClearPlaylistContentsRequestBuilder clearPlaylistContents() {
return new ClearPlaylistContentsRequestBuilder(sdkConfiguration);
}
/**
* Delete Playlist Contents
*
* <p>Clears a playlist, only works with dumb playlists. Returns the playlist.
*
* @param playlistID the ID of the playlist
* @return The response from the API call
* @throws Exception if the API call fails
*/
public ClearPlaylistContentsResponse clearPlaylistContents(double playlistID) throws Exception {
ClearPlaylistContentsRequest request =
ClearPlaylistContentsRequest
.builder()
.playlistID(playlistID)
.build();
RequestOperation<ClearPlaylistContentsRequest, ClearPlaylistContentsResponse> operation
= new ClearPlaylistContents.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
/**
* Adding to a Playlist
*
* <p>Adds a generator to a playlist, same parameters as the POST to create. With a dumb playlist, this adds the specified items to the playlist.
* With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
*
* @return The call builder
*/
public AddPlaylistContentsRequestBuilder addPlaylistContents() {
return new AddPlaylistContentsRequestBuilder(sdkConfiguration);
}
/**
* Adding to a Playlist
*
* <p>Adds a generator to a playlist, same parameters as the POST to create. With a dumb playlist, this adds the specified items to the playlist.
* With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
*
* @param playlistID the ID of the playlist
* @param uri the content URI for the playlist
* @return The response from the API call
* @throws Exception if the API call fails
*/
public AddPlaylistContentsResponse addPlaylistContents(double playlistID, String uri) throws Exception {
return addPlaylistContents(playlistID, uri, Optional.empty());
}
/**
* Adding to a Playlist
*
* <p>Adds a generator to a playlist, same parameters as the POST to create. With a dumb playlist, this adds the specified items to the playlist.
* With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
*
* @param playlistID the ID of the playlist
* @param uri the content URI for the playlist
* @param playQueueID the play queue to add to a playlist
* @return The response from the API call
* @throws Exception if the API call fails
*/
public AddPlaylistContentsResponse addPlaylistContents(
double playlistID, String uri,
Optional<Double> playQueueID) throws Exception {
AddPlaylistContentsRequest request =
AddPlaylistContentsRequest
.builder()
.playlistID(playlistID)
.uri(uri)
.playQueueID(playQueueID)
.build();
RequestOperation<AddPlaylistContentsRequest, AddPlaylistContentsResponse> operation
= new AddPlaylistContents.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
/**
* Upload Playlist
*
* <p>Imports m3u playlists by passing a path on the server to scan for m3u-formatted playlist files, or a path to a single playlist file.
*
* @return The call builder
*/
public UploadPlaylistRequestBuilder uploadPlaylist() {
return new UploadPlaylistRequestBuilder(sdkConfiguration);
}
/**
* Upload Playlist
*
* <p>Imports m3u playlists by passing a path on the server to scan for m3u-formatted playlist files, or a path to a single playlist file.
*
* @param path absolute path to a directory on the server where m3u files are stored, or the absolute path to a playlist file on the server.
* If the `path` argument is a directory, that path will be scanned for playlist files to be processed.
* Each file in that directory creates a separate playlist, with a name based on the filename of the file that created it.
* The GUID of each playlist is based on the filename.
* If the `path` argument is a file, that file will be used to create a new playlist, with the name based on the filename of the file that created it.
* The GUID of each playlist is based on the filename.
*
* @param force Force overwriting of duplicate playlists.
* By default, a playlist file uploaded with the same path will overwrite the existing playlist.
* The `force` argument is used to disable overwriting.
* If the `force` argument is set to 0, a new playlist will be created suffixed with the date and time that the duplicate was uploaded.
*
* @param sectionID Possibly the section ID to upload the playlist to, we are not certain.
* @return The response from the API call
* @throws Exception if the API call fails
*/
public UploadPlaylistResponse uploadPlaylist(
String path, QueryParamForce force,
long sectionID) throws Exception {
UploadPlaylistRequest request =
UploadPlaylistRequest
.builder()
.path(path)
.force(force)
.sectionID(sectionID)
.build();
RequestOperation<UploadPlaylistRequest, UploadPlaylistResponse> operation
= new UploadPlaylist.Sync(sdkConfiguration);
return operation.handleResponse(operation.doRequest(request));
}
}