diff options
Diffstat (limited to 'MediaBrowser.Controller/Subtitles')
5 files changed, 192 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs new file mode 100644 index 000000000..e41826be5 --- /dev/null +++ b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs @@ -0,0 +1,74 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Providers; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Model.Configuration; + +namespace MediaBrowser.Controller.Subtitles +{ + public interface ISubtitleManager + { + /// <summary> + /// Occurs when [subtitle download failure]. + /// </summary> + event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure; + + /// <summary> + /// Occurs when [subtitles downloaded]. + /// </summary> + event EventHandler<SubtitleDownloadEventArgs> SubtitlesDownloaded; + + /// <summary> + /// Adds the parts. + /// </summary> + /// <param name="subtitleProviders">The subtitle providers.</param> + void AddParts(IEnumerable<ISubtitleProvider> subtitleProviders); + + /// <summary> + /// Searches the subtitles. + /// </summary> + Task<RemoteSubtitleInfo[]> SearchSubtitles(Video video, + string language, + bool? isPerfectMatch, + CancellationToken cancellationToken); + + /// <summary> + /// Searches the subtitles. + /// </summary> + /// <param name="request">The request.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{RemoteSubtitleInfo}}.</returns> + Task<RemoteSubtitleInfo[]> SearchSubtitles(SubtitleSearchRequest request, + CancellationToken cancellationToken); + + /// <summary> + /// Downloads the subtitles. + /// </summary> + Task DownloadSubtitles(Video video, string subtitleId, CancellationToken cancellationToken); + + /// <summary> + /// Downloads the subtitles. + /// </summary> + Task DownloadSubtitles(Video video, LibraryOptions libraryOptions, string subtitleId, CancellationToken cancellationToken); + + /// <summary> + /// Gets the remote subtitles. + /// </summary> + /// <param name="id">The identifier.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{SubtitleResponse}.</returns> + Task<SubtitleResponse> GetRemoteSubtitles(string id, CancellationToken cancellationToken); + + /// <summary> + /// Deletes the subtitles. + /// </summary> + Task DeleteSubtitles(BaseItem item, int index); + + /// <summary> + /// Gets the providers. + /// </summary> + SubtitleProviderInfo[] GetSupportedProviders(BaseItem item); + } +} diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs b/MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs new file mode 100644 index 000000000..2502d685d --- /dev/null +++ b/MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs @@ -0,0 +1,40 @@ +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Providers; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Subtitles +{ + public interface ISubtitleProvider + { + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + string Name { get; } + + /// <summary> + /// Gets the supported media types. + /// </summary> + /// <value>The supported media types.</value> + IEnumerable<VideoContentType> SupportedMediaTypes { get; } + + /// <summary> + /// Searches the subtitles. + /// </summary> + /// <param name="request">The request.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{RemoteSubtitleInfo}}.</returns> + Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken); + + /// <summary> + /// Gets the subtitles. + /// </summary> + /// <param name="id">The identifier.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{SubtitleResponse}.</returns> + Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken); + } +} diff --git a/MediaBrowser.Controller/Subtitles/SubtitleDownloadEventArgs.cs b/MediaBrowser.Controller/Subtitles/SubtitleDownloadEventArgs.cs new file mode 100644 index 000000000..1d204f2cb --- /dev/null +++ b/MediaBrowser.Controller/Subtitles/SubtitleDownloadEventArgs.cs @@ -0,0 +1,27 @@ +using System; +using MediaBrowser.Controller.Entities; + +namespace MediaBrowser.Controller.Subtitles +{ + public class SubtitleDownloadEventArgs + { + public BaseItem Item { get; set; } + + public string Format { get; set; } + + public string Language { get; set; } + + public bool IsForced { get; set; } + + public string Provider { get; set; } + } + + public class SubtitleDownloadFailureEventArgs + { + public BaseItem Item { get; set; } + + public string Provider { get; set; } + + public Exception Exception { get; set; } + } +} diff --git a/MediaBrowser.Controller/Subtitles/SubtitleResponse.cs b/MediaBrowser.Controller/Subtitles/SubtitleResponse.cs new file mode 100644 index 000000000..e2f6dfc97 --- /dev/null +++ b/MediaBrowser.Controller/Subtitles/SubtitleResponse.cs @@ -0,0 +1,12 @@ +using System.IO; + +namespace MediaBrowser.Controller.Subtitles +{ + public class SubtitleResponse + { + public string Language { get; set; } + public string Format { get; set; } + public bool IsForced { get; set; } + public Stream Stream { get; set; } + } +}
\ No newline at end of file diff --git a/MediaBrowser.Controller/Subtitles/SubtitleSearchRequest.cs b/MediaBrowser.Controller/Subtitles/SubtitleSearchRequest.cs new file mode 100644 index 000000000..84bf28c05 --- /dev/null +++ b/MediaBrowser.Controller/Subtitles/SubtitleSearchRequest.cs @@ -0,0 +1,39 @@ +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Subtitles +{ + public class SubtitleSearchRequest : IHasProviderIds + { + public string Language { get; set; } + public string TwoLetterISOLanguageName { get; set; } + + public VideoContentType ContentType { get; set; } + + public string MediaPath { get; set; } + public string SeriesName { get; set; } + public string Name { get; set; } + public int? IndexNumber { get; set; } + public int? IndexNumberEnd { get; set; } + public int? ParentIndexNumber { get; set; } + public int? ProductionYear { get; set; } + public long? RuntimeTicks { get; set; } + public bool IsPerfectMatch { get; set; } + public Dictionary<string, string> ProviderIds { get; set; } + + public bool SearchAllProviders { get; set; } + public string[] DisabledSubtitleFetchers { get; set; } + public string[] SubtitleFetcherOrder { get; set; } + + public SubtitleSearchRequest() + { + SearchAllProviders = true; + ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); + + DisabledSubtitleFetchers = new string[] {}; + SubtitleFetcherOrder = new string[] {}; + } + } +}
\ No newline at end of file |
