ISubtitleProvider.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using MediaBrowser.Model.Entities;
  2. using MediaBrowser.Model.Providers;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace MediaBrowser.Controller.Subtitles
  9. {
  10. public interface ISubtitleProvider
  11. {
  12. /// <summary>
  13. /// Gets the name.
  14. /// </summary>
  15. /// <value>The name.</value>
  16. string Name { get; }
  17. /// <summary>
  18. /// Gets the supported media types.
  19. /// </summary>
  20. /// <value>The supported media types.</value>
  21. IEnumerable<SubtitleMediaType> SupportedMediaTypes { get; }
  22. /// <summary>
  23. /// Searches the subtitles.
  24. /// </summary>
  25. /// <param name="request">The request.</param>
  26. /// <param name="cancellationToken">The cancellation token.</param>
  27. /// <returns>Task{IEnumerable{RemoteSubtitleInfo}}.</returns>
  28. Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken);
  29. /// <summary>
  30. /// Gets the subtitles.
  31. /// </summary>
  32. /// <param name="id">The identifier.</param>
  33. /// <param name="cancellationToken">The cancellation token.</param>
  34. /// <returns>Task{SubtitleResponse}.</returns>
  35. Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken);
  36. }
  37. public enum SubtitleMediaType
  38. {
  39. Episode = 0,
  40. Movie = 1
  41. }
  42. public class SubtitleResponse
  43. {
  44. public string Language { get; set; }
  45. public string Format { get; set; }
  46. public Stream Stream { get; set; }
  47. }
  48. public class SubtitleSearchRequest : IHasProviderIds
  49. {
  50. public string Language { get; set; }
  51. public SubtitleMediaType ContentType { get; set; }
  52. public string MediaPath { get; set; }
  53. public string SeriesName { get; set; }
  54. public string Name { get; set; }
  55. public int? IndexNumber { get; set; }
  56. public int? IndexNumberEnd { get; set; }
  57. public int? ParentIndexNumber { get; set; }
  58. public int? ProductionYear { get; set; }
  59. public Dictionary<string, string> ProviderIds { get; set; }
  60. public SubtitleSearchRequest()
  61. {
  62. ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
  63. }
  64. }
  65. }