From a86b71899ec52c44ddc6c3018e8cc5e9d7ff4d62 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Thu, 27 Dec 2018 18:27:57 -0500 Subject: Add GPL modules --- .../Subtitles/ISubtitleManager.cs | 74 ++++++++++++++++++++++ .../Subtitles/ISubtitleProvider.cs | 40 ++++++++++++ .../Subtitles/SubtitleDownloadEventArgs.cs | 27 ++++++++ .../Subtitles/SubtitleResponse.cs | 12 ++++ .../Subtitles/SubtitleSearchRequest.cs | 39 ++++++++++++ 5 files changed, 192 insertions(+) create mode 100644 MediaBrowser.Controller/Subtitles/ISubtitleManager.cs create mode 100644 MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs create mode 100644 MediaBrowser.Controller/Subtitles/SubtitleDownloadEventArgs.cs create mode 100644 MediaBrowser.Controller/Subtitles/SubtitleResponse.cs create mode 100644 MediaBrowser.Controller/Subtitles/SubtitleSearchRequest.cs (limited to 'MediaBrowser.Controller/Subtitles') diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs new file mode 100644 index 0000000000..e41826be5b --- /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 + { + /// + /// Occurs when [subtitle download failure]. + /// + event EventHandler SubtitleDownloadFailure; + + /// + /// Occurs when [subtitles downloaded]. + /// + event EventHandler SubtitlesDownloaded; + + /// + /// Adds the parts. + /// + /// The subtitle providers. + void AddParts(IEnumerable subtitleProviders); + + /// + /// Searches the subtitles. + /// + Task SearchSubtitles(Video video, + string language, + bool? isPerfectMatch, + CancellationToken cancellationToken); + + /// + /// Searches the subtitles. + /// + /// The request. + /// The cancellation token. + /// Task{IEnumerable{RemoteSubtitleInfo}}. + Task SearchSubtitles(SubtitleSearchRequest request, + CancellationToken cancellationToken); + + /// + /// Downloads the subtitles. + /// + Task DownloadSubtitles(Video video, string subtitleId, CancellationToken cancellationToken); + + /// + /// Downloads the subtitles. + /// + Task DownloadSubtitles(Video video, LibraryOptions libraryOptions, string subtitleId, CancellationToken cancellationToken); + + /// + /// Gets the remote subtitles. + /// + /// The identifier. + /// The cancellation token. + /// Task{SubtitleResponse}. + Task GetRemoteSubtitles(string id, CancellationToken cancellationToken); + + /// + /// Deletes the subtitles. + /// + Task DeleteSubtitles(BaseItem item, int index); + + /// + /// Gets the providers. + /// + SubtitleProviderInfo[] GetSupportedProviders(BaseItem item); + } +} diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs b/MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs new file mode 100644 index 0000000000..2502d685de --- /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 + { + /// + /// Gets the name. + /// + /// The name. + string Name { get; } + + /// + /// Gets the supported media types. + /// + /// The supported media types. + IEnumerable SupportedMediaTypes { get; } + + /// + /// Searches the subtitles. + /// + /// The request. + /// The cancellation token. + /// Task{IEnumerable{RemoteSubtitleInfo}}. + Task> Search(SubtitleSearchRequest request, CancellationToken cancellationToken); + + /// + /// Gets the subtitles. + /// + /// The identifier. + /// The cancellation token. + /// Task{SubtitleResponse}. + Task GetSubtitles(string id, CancellationToken cancellationToken); + } +} diff --git a/MediaBrowser.Controller/Subtitles/SubtitleDownloadEventArgs.cs b/MediaBrowser.Controller/Subtitles/SubtitleDownloadEventArgs.cs new file mode 100644 index 0000000000..1d204f2cbd --- /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 0000000000..e2f6dfc97b --- /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 0000000000..84bf28c05b --- /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 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(StringComparer.OrdinalIgnoreCase); + + DisabledSubtitleFetchers = new string[] {}; + SubtitleFetcherOrder = new string[] {}; + } + } +} \ No newline at end of file -- cgit v1.2.3