using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Notifications; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Search; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Session; using MediaBrowser.Model.System; using MediaBrowser.Model.Tasks; using MediaBrowser.Model.Users; using System; using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; namespace MediaBrowser.Model.ApiClient { /// /// Interface IApiClient /// public interface IApiClient : IDisposable { /// /// Occurs when [server location changed]. /// event EventHandler ServerLocationChanged; /// /// Occurs when [HTTP response received]. /// event EventHandler HttpResponseReceived; /// /// Gets the API URL. /// /// The handler. /// System.String. string GetApiUrl(string handler); /// /// Gets the game system summaries async. /// /// The cancellation token. /// Task{List{GameSystemSummary}}. Task> GetGameSystemSummariesAsync(CancellationToken cancellationToken); /// /// Gets the async. /// /// /// The URL. /// The cancellation token. /// Task{``0}. Task GetAsync(string url, CancellationToken cancellationToken) where T : class; /// /// Reports the capabilities. /// /// The session identifier. /// The capabilities. /// The cancellation token. /// Task. Task ReportCapabilities(string sessionId, ClientCapabilities capabilities, CancellationToken cancellationToken); /// /// Gets the index of the game players. /// /// The user id. /// The cancellation token. /// Task{List{ItemIndex}}. Task> GetGamePlayerIndex(string userId, CancellationToken cancellationToken); /// /// Gets the index of the year. /// /// The user id. /// The include item types. /// The cancellation token. /// Task{List{ItemIndex}}. Task> GetYearIndex(string userId, string[] includeItemTypes, CancellationToken cancellationToken); /// /// Gets the critic reviews. /// /// The item id. /// The cancellation token. /// The start index. /// The limit. /// Task{ItemReviewsResult}. Task> GetCriticReviews(string itemId, CancellationToken cancellationToken, int? startIndex = null, int? limit = null); /// /// Gets the theme songs async. /// /// The user id. /// The item id. /// if set to true [inherit from parents]. /// The cancellation token. /// Task{ThemeMediaResult}. Task GetThemeSongsAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken); /// /// Gets the search hints async. /// /// The query. /// Task{SearchHintResult}. Task GetSearchHintsAsync(SearchQuery query); /// /// Gets the theme videos async. /// /// The user id. /// The item id. /// if set to true [inherit from parents]. /// The cancellation token. /// Task{ThemeMediaResult}. Task GetThemeVideosAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken); /// /// Gets all theme media async. /// /// The user id. /// The item id. /// if set to true [inherit from parents]. /// The cancellation token. /// Task{AllThemeMediaResult}. Task GetAllThemeMediaAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken); /// /// Marks the notifications read. /// /// The user id. /// The notification id list. /// if set to true [is read]. /// Task. Task MarkNotificationsRead(string userId, IEnumerable notificationIdList, bool isRead); /// /// Updates the notification. /// /// The notification. /// Task. Task UpdateNotification(Notification notification); /// /// Adds the notification. /// /// The notification. /// Task{Notification}. Task AddNotification(Notification notification); /// /// Gets the notifications summary. /// /// The user id. /// Task{NotificationsSummary}. Task GetNotificationsSummary(string userId); /// /// Gets the notifications async. /// /// The query. /// Task{NotificationResult}. Task GetNotificationsAsync(NotificationQuery query); /// /// Gets an image stream based on a url /// /// The URL. /// The cancellation token. /// Task{Stream}. /// url Task GetImageStreamAsync(string url, CancellationToken cancellationToken); /// /// Gets a BaseItem /// /// The id. /// The user id. /// Task{BaseItemDto}. /// id Task GetItemAsync(string id, string userId); /// /// Gets the intros async. /// /// The item id. /// The user id. /// Task{ItemsResult}. Task GetIntrosAsync(string itemId, string userId); /// /// Gets a BaseItem /// /// The user id. /// Task{BaseItemDto}. /// userId Task GetRootFolderAsync(string userId); /// /// Gets the users async. /// /// The query. /// Task{UserDto[]}. Task GetUsersAsync(UserQuery query); /// /// Gets the public users async. /// /// The cancellation token. /// Task{UserDto[]}. Task GetPublicUsersAsync(CancellationToken cancellationToken); /// /// Gets active client sessions. /// /// The query. /// Task{SessionInfoDto[]}. Task GetClientSessionsAsync(SessionQuery query); /// /// Gets the item counts async. /// /// The query. /// Task{ItemCounts}. Task GetItemCountsAsync(ItemCountsQuery query); /// /// Gets the episodes asynchronous. /// /// The query. /// Task{ItemsResult}. Task GetEpisodesAsync(EpisodeQuery query); /// /// Gets the seasons asynchronous. /// /// The query. /// Task{ItemsResult}. Task GetSeasonsAsync(SeasonQuery query); /// /// Queries for items /// /// The query. /// Task{ItemsResult}. /// query Task GetItemsAsync(ItemQuery query); /// /// Gets the instant mix from song async. /// /// The query. /// Task{ItemsResult}. Task GetInstantMixFromSongAsync(SimilarItemsQuery query); /// /// Gets the instant mix from album async. /// /// The query. /// Task{ItemsResult}. Task GetInstantMixFromAlbumAsync(SimilarItemsQuery query); /// /// Gets the instant mix from artist async. /// /// The query. /// Task{ItemsResult}. Task GetInstantMixFromArtistAsync(SimilarItemsByNameQuery query); /// /// Gets the instant mix from music genre async. /// /// The query. /// Task{ItemsResult}. Task GetInstantMixFromMusicGenreAsync(SimilarItemsByNameQuery query); /// /// Gets the similar movies async. /// /// The query. /// Task{ItemsResult}. Task GetSimilarMoviesAsync(SimilarItemsQuery query); /// /// Gets the similar trailers async. /// /// The query. /// Task{ItemsResult}. Task GetSimilarTrailersAsync(SimilarItemsQuery query); /// /// Gets the similar series async. /// /// The query. /// Task{ItemsResult}. Task GetSimilarSeriesAsync(SimilarItemsQuery query); /// /// Gets the similar albums async. /// /// The query. /// Task{ItemsResult}. Task GetSimilarAlbumsAsync(SimilarItemsQuery query); /// /// Gets the similar games async. /// /// The query. /// Task{ItemsResult}. Task GetSimilarGamesAsync(SimilarItemsQuery query); /// /// Gets the people async. /// /// The query. /// Task{ItemsResult}. /// userId Task GetPeopleAsync(PersonsQuery query); /// /// Gets the artists. /// /// The query. /// Task{ItemsResult}. /// userId Task GetArtistsAsync(ArtistsQuery query); /// /// Gets a studio /// /// The name. /// The user id. /// Task{BaseItemDto}. /// userId Task GetStudioAsync(string name, string userId); /// /// Gets the next up async. /// /// The query. /// Task{ItemsResult}. Task GetNextUpEpisodesAsync(NextUpQuery query); /// /// Gets the upcoming episodes asynchronous. /// /// The query. /// Task{ItemsResult}. Task GetUpcomingEpisodesAsync(NextUpQuery query); /// /// Gets a genre /// /// The name. /// The user id. /// Task{BaseItemDto}. /// userId Task GetGenreAsync(string name, string userId); /// /// Gets the genres async. /// /// The query. /// Task{ItemsResult}. Task GetGenresAsync(ItemsByNameQuery query); /// /// Gets the music genres async. /// /// The query. /// Task{ItemsResult}. Task GetMusicGenresAsync(ItemsByNameQuery query); /// /// Gets the game genres async. /// /// The query. /// Task{ItemsResult}. Task GetGameGenresAsync(ItemsByNameQuery query); /// /// Gets the studios async. /// /// The query. /// Task{ItemsResult}. Task GetStudiosAsync(ItemsByNameQuery query); /// /// Gets the music genre async. /// /// The name. /// The user id. /// Task{BaseItemDto}. Task GetMusicGenreAsync(string name, string userId); /// /// Gets the game genre async. /// /// The name. /// The user id. /// Task{BaseItemDto}. Task GetGameGenreAsync(string name, string userId); /// /// Gets the artist async. /// /// The name. /// The user id. /// Task{BaseItemDto}. /// name Task GetArtistAsync(string name, string userId); /// /// Restarts the server. /// /// Task. Task RestartServerAsync(); /// /// Gets the system status async. /// /// Task{SystemInfo}. Task GetSystemInfoAsync(); /// /// Gets a person /// /// The name. /// The user id. /// Task{BaseItemDto}. /// userId Task GetPersonAsync(string name, string userId); /// /// Gets a list of plugins installed on the server /// /// Task{PluginInfo[]}. Task GetInstalledPluginsAsync(); /// /// Gets the current server configuration /// /// Task{ServerConfiguration}. Task GetServerConfigurationAsync(); /// /// Gets the scheduled tasks. /// /// Task{TaskInfo[]}. Task GetScheduledTasksAsync(); /// /// Gets the scheduled task async. /// /// The id. /// Task{TaskInfo}. /// id Task GetScheduledTaskAsync(Guid id); /// /// Gets a user by id /// /// The id. /// Task{UserDto}. /// id Task GetUserAsync(string id); /// /// Gets the parental ratings async. /// /// Task{List{ParentalRating}}. Task> GetParentalRatingsAsync(); /// /// Gets local trailers for an item /// /// The user id. /// The item id. /// Task{ItemsResult}. /// query Task GetLocalTrailersAsync(string userId, string itemId); /// /// Gets special features for an item /// /// The user id. /// The item id. /// Task{BaseItemDto[]}. /// userId Task GetSpecialFeaturesAsync(string userId, string itemId); /// /// Gets the cultures async. /// /// Task{CultureDto[]}. Task GetCulturesAsync(); /// /// Gets the countries async. /// /// Task{CountryInfo[]}. Task GetCountriesAsync(); /// /// Marks the played async. /// /// The item id. /// The user id. /// The date played. /// Task{UserItemDataDto}. Task MarkPlayedAsync(string itemId, string userId, DateTime? datePlayed); /// /// Marks the unplayed async. /// /// The item id. /// The user id. /// Task{UserItemDataDto}. Task MarkUnplayedAsync(string itemId, string userId); /// /// Updates the favorite status async. /// /// The item id. /// The user id. /// if set to true [is favorite]. /// Task. /// itemId Task UpdateFavoriteStatusAsync(string itemId, string userId, bool isFavorite); /// /// Reports to the server that the user has begun playing an item /// /// The information. /// Task{UserItemDataDto}. /// itemId Task ReportPlaybackStartAsync(PlaybackStartInfo info); /// /// Reports playback progress to the server /// /// The information. /// Task{UserItemDataDto}. /// itemId Task ReportPlaybackProgressAsync(PlaybackProgressInfo info); /// /// Reports to the server that the user has stopped playing an item /// /// The information. /// Task{UserItemDataDto}. /// itemId Task ReportPlaybackStoppedAsync(PlaybackStopInfo info); /// /// Instructs antoher client to browse to a library item. /// /// The session id. /// The id of the item to browse to. /// The name of the item to browse to. /// The type of the item to browse to. /// Optional ui context (movies, music, tv, games, etc). The client is free to ignore this. /// Task. Task SendBrowseCommandAsync(string sessionId, string itemId, string itemName, string itemType, string context); /// /// Sends the playstate command async. /// /// The session id. /// The request. /// Task. Task SendPlaystateCommandAsync(string sessionId, PlaystateRequest request); /// /// Sends the play command async. /// /// The session id. /// The request. /// Task. /// sessionId /// or /// request Task SendPlayCommandAsync(string sessionId, PlayRequest request); /// /// Sends the command asynchronous. /// /// The session identifier. /// The command. /// Task. Task SendCommandAsync(string sessionId, GeneralCommand command); /// /// Instructs the client to display a message to the user /// /// The session id. /// The command. /// Task. Task SendMessageCommandAsync(string sessionId, MessageCommand command); /// /// Clears a user's rating for an item /// /// The item id. /// The user id. /// Task{UserItemDataDto}. /// itemId Task ClearUserItemRatingAsync(string itemId, string userId); /// /// Updates a user's rating for an item, based on likes or dislikes /// /// The item id. /// The user id. /// if set to true [likes]. /// Task. /// itemId Task UpdateUserItemRatingAsync(string itemId, string userId, bool likes); /// /// Authenticates a user and returns the result /// /// The username. /// The sha1 hash. /// Task. /// userId Task AuthenticateUserAsync(string username, byte[] sha1Hash); /// /// Updates the server configuration async. /// /// The configuration. /// Task. /// configuration Task UpdateServerConfigurationAsync(ServerConfiguration configuration); /// /// Updates the scheduled task triggers. /// /// The id. /// The triggers. /// Task{RequestResult}. /// id Task UpdateScheduledTaskTriggersAsync(Guid id, TaskTriggerInfo[] triggers); /// /// Gets the display preferences. /// /// The id. /// The user id. /// The client. /// The cancellation token. /// Task{BaseItemDto}. Task GetDisplayPreferencesAsync(string id, string userId, string client, CancellationToken cancellationToken); /// /// Updates display preferences for a user /// /// The display preferences. /// The user id. /// The client. /// The cancellation token. /// Task{DisplayPreferences}. /// userId Task UpdateDisplayPreferencesAsync(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken); /// /// Posts a set of data to a url, and deserializes the return stream into T /// /// /// The URL. /// The args. /// The cancellation token. /// Task{``0}. Task PostAsync(string url, Dictionary args, CancellationToken cancellationToken) where T : class; /// /// This is a helper around getting a stream from the server that contains serialized data /// /// The URL. /// Task{Stream}. Task GetSerializedStreamAsync(string url); /// /// Gets the json serializer. /// /// The json serializer. IJsonSerializer JsonSerializer { get; set; } /// /// Gets or sets the server host name (myserver or 192.168.x.x) /// /// The name of the server host. string ServerHostName { get; } /// /// Gets or sets the port number used by the API /// /// The server API port. int ServerApiPort { get; } /// /// Changes the server location. /// /// Name of the host. /// The API port. void ChangeServerLocation(string hostName, int apiPort); /// /// Gets or sets the type of the client. /// /// The type of the client. string ClientName { get; set; } /// /// Gets or sets the name of the device. /// /// The name of the device. string DeviceName { get; set; } /// /// Gets or sets the device id. /// /// The device id. string DeviceId { get; set; } /// /// Gets or sets the current user id. /// /// The current user id. string CurrentUserId { get; set; } /// /// Gets the image URL. /// /// The item. /// The options. /// System.String. /// item string GetImageUrl(BaseItemDto item, ImageOptions options); /// /// Gets the image URL. /// /// The item. /// The options. /// System.String. string GetImageUrl(ChannelInfoDto item, ImageOptions options); /// /// Gets the image URL. /// /// The item. /// The options. /// System.String. string GetImageUrl(RecordingInfoDto item, ImageOptions options); /// /// Gets the image URL. /// /// The item. /// The options. /// System.String. string GetImageUrl(ProgramInfoDto item, ImageOptions options); /// /// Gets an image url that can be used to download an image from the api /// /// The Id of the item /// The options. /// System.String. /// itemId string GetImageUrl(string itemId, ImageOptions options); /// /// Gets the user image URL. /// /// The user. /// The options. /// System.String. /// user string GetUserImageUrl(UserDto user, ImageOptions options); /// /// Gets an image url that can be used to download an image from the api /// /// The Id of the user /// The options. /// System.String. /// userId string GetUserImageUrl(string userId, ImageOptions options); /// /// Gets the person image URL. /// /// The item. /// The options. /// System.String. /// item string GetPersonImageUrl(BaseItemPerson item, ImageOptions options); /// /// Gets an image url that can be used to download an image from the api /// /// The name of the person /// The options. /// System.String. /// name string GetPersonImageUrl(string name, ImageOptions options); /// /// Gets an image url that can be used to download an image from the api /// /// The year. /// The options. /// System.String. string GetYearImageUrl(int year, ImageOptions options); /// /// Gets an image url that can be used to download an image from the api /// /// The name. /// The options. /// System.String. /// name string GetGenreImageUrl(string name, ImageOptions options); /// /// Gets the music genre image URL. /// /// The name. /// The options. /// System.String. string GetMusicGenreImageUrl(string name, ImageOptions options); /// /// Gets the game genre image URL. /// /// The name. /// The options. /// System.String. string GetGameGenreImageUrl(string name, ImageOptions options); /// /// Gets an image url that can be used to download an image from the api /// /// The name. /// The options. /// System.String. /// name string GetStudioImageUrl(string name, ImageOptions options); /// /// Gets the artist image URL. /// /// The name. /// The options. /// System.String. /// name string GetArtistImageUrl(string name, ImageOptions options); /// /// This is a helper to get a list of backdrop url's from a given ApiBaseItemWrapper. If the actual item does not have any backdrops it will return backdrops from the first parent that does. /// /// A given item. /// The options. /// System.String[][]. /// item string[] GetBackdropImageUrls(BaseItemDto item, ImageOptions options); /// /// This is a helper to get the logo image url from a given ApiBaseItemWrapper. If the actual item does not have a logo, it will return the logo from the first parent that does, or null. /// /// A given item. /// The options. /// System.String. /// item string GetLogoImageUrl(BaseItemDto item, ImageOptions options); /// /// Gets the art image URL. /// /// The item. /// The options. /// System.String. string GetArtImageUrl(BaseItemDto item, ImageOptions options); /// /// Gets the thumb image URL. /// /// The item. /// The options. /// System.String. string GetThumbImageUrl(BaseItemDto item, ImageOptions options); /// /// Gets the url needed to stream an audio file /// /// The options. /// System.String. /// options string GetAudioStreamUrl(StreamOptions options); /// /// Gets the url needed to stream a video file /// /// The options. /// System.String. /// options string GetVideoStreamUrl(VideoStreamOptions options); /// /// Formulates a url for streaming audio using the HLS protocol /// /// The options. /// System.String. /// options string GetHlsAudioStreamUrl(StreamOptions options); /// /// Formulates a url for streaming video using the HLS protocol /// /// The options. /// System.String. /// options string GetHlsVideoStreamUrl(VideoStreamOptions options); /// /// Gets the live tv information asynchronous. /// /// The cancellation token. /// Task{LiveTvInfo}. Task GetLiveTvInfoAsync(CancellationToken cancellationToken); /// /// Gets the live tv channels asynchronous. /// /// The query. /// The cancellation token. /// Task{LiveTvInfo}. Task> GetLiveTvChannelsAsync(ChannelQuery query, CancellationToken cancellationToken); /// /// Gets the live tv channel asynchronous. /// /// The identifier. /// The user identifier. /// The cancellation token. /// Task{ChannelInfoDto}. Task GetLiveTvChannelAsync(string id, string userId, CancellationToken cancellationToken); /// /// Gets the live tv recordings asynchronous. /// /// The query. /// The cancellation token. /// Task{QueryResult{RecordingInfoDto}}. Task> GetLiveTvRecordingsAsync(RecordingQuery query, CancellationToken cancellationToken); /// /// Gets the live tv recording asynchronous. /// /// The identifier. /// The user identifier. /// The cancellation token. /// Task{RecordingInfoDto}. Task GetLiveTvRecordingAsync(string id, string userId, CancellationToken cancellationToken); /// /// Gets the live tv recording groups asynchronous. /// /// The query. /// The cancellation token. /// Task{QueryResult{RecordingGroupDto}}. Task> GetLiveTvRecordingGroupsAsync(RecordingGroupQuery query, CancellationToken cancellationToken); /// /// Gets the live tv recording group asynchronous. /// /// The identifier. /// The user identifier. /// The cancellation token. /// Task{RecordingGroupDto}. Task GetLiveTvRecordingGroupAsync(string id, string userId, CancellationToken cancellationToken); /// /// Gets the live tv timers asynchronous. /// /// The query. /// The cancellation token. /// Task{QueryResult{TimerInfoDto}}. Task> GetLiveTvTimersAsync(TimerQuery query, CancellationToken cancellationToken); /// /// Gets the live tv programs asynchronous. /// /// The query. /// The cancellation token. /// Task{QueryResult{ProgramInfoDto}}. Task> GetLiveTvProgramsAsync(ProgramQuery query, CancellationToken cancellationToken); /// /// Gets the live tv program asynchronous. /// /// The identifier. /// The user identifier. /// The cancellation token. /// Task{ProgramInfoDto}. Task GetLiveTvProgramAsync(string id, string userId, CancellationToken cancellationToken); /// /// Gets the recommended live tv programs asynchronous. /// /// The query. /// The cancellation token. /// Task{QueryResult{ProgramInfoDto}}. Task> GetRecommendedLiveTvProgramsAsync(RecommendedProgramQuery query, CancellationToken cancellationToken); /// /// Creates the live tv timer asynchronous. /// /// The timer. /// The cancellation token. /// Task. Task CreateLiveTvTimerAsync(BaseTimerInfoDto timer, CancellationToken cancellationToken); /// /// Updates the live tv timer asynchronous. /// /// The timer. /// The cancellation token. /// Task. Task UpdateLiveTvTimerAsync(TimerInfoDto timer, CancellationToken cancellationToken); /// /// Creates the live tv series timer asynchronous. /// /// The timer. /// The cancellation token. /// Task. Task CreateLiveTvSeriesTimerAsync(SeriesTimerInfoDto timer, CancellationToken cancellationToken); /// /// Updates the live tv series timer asynchronous. /// /// The timer. /// The cancellation token. /// Task. Task UpdateLiveTvSeriesTimerAsync(SeriesTimerInfoDto timer, CancellationToken cancellationToken); /// /// Gets the live tv timer asynchronous. /// /// The identifier. /// The cancellation token. /// Task{TimerInfoDto}. Task GetLiveTvTimerAsync(string id, CancellationToken cancellationToken); /// /// Gets the live tv series timers asynchronous. /// /// The query. /// The cancellation token. /// Task{QueryResult{SeriesTimerInfoDto}}. Task> GetLiveTvSeriesTimersAsync(SeriesTimerQuery query, CancellationToken cancellationToken); /// /// Gets the live tv series timer asynchronous. /// /// The identifier. /// The cancellation token. /// Task{SeriesTimerInfoDto}. Task GetLiveTvSeriesTimerAsync(string id, CancellationToken cancellationToken); /// /// Cancels the live tv timer asynchronous. /// /// The identifier. /// The cancellation token. /// Task. Task CancelLiveTvTimerAsync(string id, CancellationToken cancellationToken); /// /// Cancels the live tv series timer asynchronous. /// /// The identifier. /// The cancellation token. /// Task. Task CancelLiveTvSeriesTimerAsync(string id, CancellationToken cancellationToken); /// /// Deletes the live tv recording asynchronous. /// /// The identifier. /// The cancellation token. /// Task. Task DeleteLiveTvRecordingAsync(string id, CancellationToken cancellationToken); /// /// Gets the default timer information. /// /// The cancellation token. /// Task{SeriesTimerInfoDto}. Task GetDefaultLiveTvTimerInfo(CancellationToken cancellationToken); /// /// Gets the live tv guide information. /// /// The cancellation token. /// Task{GuideInfo}. Task GetLiveTvGuideInfo(CancellationToken cancellationToken); /// /// Gets the default timer information. /// /// The program identifier. /// The cancellation token. /// Task{SeriesTimerInfoDto}. Task GetDefaultLiveTvTimerInfo(string programId, CancellationToken cancellationToken); } }