diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-05-06 22:28:19 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-05-06 22:28:19 -0400 |
| commit | 0d025f7fb620bf2a24ca9aa4e5994f132e02e7c0 (patch) | |
| tree | 76137f5f868ed81725d29bbdc6ac0e3b57c304d8 /MediaBrowser.Controller/Subtitles | |
| parent | e1dd361c7bf05af49d9210ab679e85fa00870990 (diff) | |
beginning remote subtitle downloading
Diffstat (limited to 'MediaBrowser.Controller/Subtitles')
| -rw-r--r-- | MediaBrowser.Controller/Subtitles/ISubtitleManager.cs | 50 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs | 75 |
2 files changed, 125 insertions, 0 deletions
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 + { + /// <summary> + /// Adds the parts. + /// </summary> + /// <param name="subtitleProviders">The subtitle providers.</param> + void AddParts(IEnumerable<ISubtitleProvider> subtitleProviders); + + /// <summary> + /// Searches the subtitles. + /// </summary> + /// <param name="video">The video.</param> + /// <param name="language">The language.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{RemoteSubtitleInfo}}.</returns> + Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitles(Video video, + string language, + 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<IEnumerable<RemoteSubtitleInfo>> SearchSubtitles(SubtitleSearchRequest request, + CancellationToken cancellationToken); + + /// <summary> + /// Downloads the subtitles. + /// </summary> + /// <param name="video">The video.</param> + /// <param name="subtitleId">The subtitle identifier.</param> + /// <param name="providerName">Name of the provider.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task.</returns> + 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 + { + /// <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<SubtitleMediaType> 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>> SearchSubtitles(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); + } + + 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<string, string> ProviderIds { get; set; } + + public SubtitleSearchRequest() + { + ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); + } + } +} |
