mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 23:58:57 +00:00
beginning remote subtitle downloading
This commit is contained in:
50
MediaBrowser.Controller/Subtitles/ISubtitleManager.cs
Normal file
50
MediaBrowser.Controller/Subtitles/ISubtitleManager.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
75
MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs
Normal file
75
MediaBrowser.Controller/Subtitles/ISubtitleProvider.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user