From 0d025f7fb620bf2a24ca9aa4e5994f132e02e7c0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 6 May 2014 22:28:19 -0400 Subject: beginning remote subtitle downloading --- .../MediaBrowser.Controller.csproj | 3 +- .../Providers/ISubtitleProvider.cs | 66 ------------------- .../Subtitles/ISubtitleManager.cs | 50 +++++++++++++++ .../Subtitles/ISubtitleProvider.cs | 75 ++++++++++++++++++++++ 4 files changed, 127 insertions(+), 67 deletions(-) delete mode 100644 MediaBrowser.Controller/Providers/ISubtitleProvider.cs create mode 100644 MediaBrowser.Controller/Subtitles/ISubtitleManager.cs create mode 100644 MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 5e259359f..6a3709dda 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -191,7 +191,8 @@ - + + diff --git a/MediaBrowser.Controller/Providers/ISubtitleProvider.cs b/MediaBrowser.Controller/Providers/ISubtitleProvider.cs deleted file mode 100644 index 09ca27e30..000000000 --- a/MediaBrowser.Controller/Providers/ISubtitleProvider.cs +++ /dev/null @@ -1,66 +0,0 @@ -using MediaBrowser.Model.Entities; -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Controller.Providers -{ - public interface ISubtitleProvider - { - /// - /// Gets the name. - /// - /// The name. - string Name { get; } - - /// - /// Gets the supported media types. - /// - /// The supported media types. - IEnumerable SupportedMediaTypes { get; } - - /// - /// Gets the subtitles. - /// - /// The request. - /// The cancellation token. - /// Task{SubtitleResponse}. - Task GetSubtitles(SubtitleRequest request, CancellationToken cancellationToken); - } - - public enum SubtitleMediaType - { - Episode = 0, - Movie = 1 - } - - public class SubtitleResponse - { - public string Format { get; set; } - public bool HasContent { get; set; } - public Stream Stream { get; set; } - } - - public class SubtitleRequest : IHasProviderIds - { - public string Language { get; set; } - - public SubtitleMediaType 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 Dictionary ProviderIds { get; set; } - - public SubtitleRequest() - { - ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - } - } -} diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs new file mode 100644 index 000000000..8b0ef223c --- /dev/null +++ b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs @@ -0,0 +1,50 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Providers; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Subtitles +{ + public interface ISubtitleManager + { + /// + /// Adds the parts. + /// + /// The subtitle providers. + void AddParts(IEnumerable subtitleProviders); + + /// + /// Searches the subtitles. + /// + /// The video. + /// The language. + /// The cancellation token. + /// Task{IEnumerable{RemoteSubtitleInfo}}. + Task> SearchSubtitles(Video video, + string language, + CancellationToken cancellationToken); + + /// + /// Searches the subtitles. + /// + /// The request. + /// The cancellation token. + /// Task{IEnumerable{RemoteSubtitleInfo}}. + Task> SearchSubtitles(SubtitleSearchRequest request, + CancellationToken cancellationToken); + + /// + /// Downloads the subtitles. + /// + /// The video. + /// The subtitle identifier. + /// Name of the provider. + /// The cancellation token. + /// Task. + Task DownloadSubtitles(Video video, + string subtitleId, + string providerName, + CancellationToken cancellationToken); + } +} diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs b/MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs new file mode 100644 index 000000000..1409b7d50 --- /dev/null +++ b/MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs @@ -0,0 +1,75 @@ +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Providers; +using System; +using System.Collections.Generic; +using System.IO; +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> SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken); + + /// + /// Gets the subtitles. + /// + /// The identifier. + /// The cancellation token. + /// Task{SubtitleResponse}. + Task GetSubtitles(string id, CancellationToken cancellationToken); + } + + public enum SubtitleMediaType + { + Episode = 0, + Movie = 1 + } + + public class SubtitleResponse + { + public string Language { get; set; } + public string Format { get; set; } + public Stream Stream { get; set; } + } + + public class SubtitleSearchRequest : IHasProviderIds + { + public string Language { get; set; } + + public SubtitleMediaType 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 Dictionary ProviderIds { get; set; } + + public SubtitleSearchRequest() + { + ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); + } + } +} -- cgit v1.2.3