|
@@ -1,4 +1,6 @@
|
|
|
-using MediaBrowser.Controller.Entities;
|
|
|
+using System.IO;
|
|
|
+using System.Linq;
|
|
|
+using MediaBrowser.Controller.Entities;
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
using MediaBrowser.Controller.MediaEncoding;
|
|
|
using MediaBrowser.Controller.Net;
|
|
@@ -9,37 +11,13 @@ using MediaBrowser.Model.Providers;
|
|
|
using ServiceStack;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
-using System.IO;
|
|
|
-using System.Linq;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
-namespace MediaBrowser.Api.Library
|
|
|
+namespace MediaBrowser.Api.Subtitles
|
|
|
{
|
|
|
- [Route("/Videos/{Id}/{MediaSourceId}/Subtitles/{Index}/Stream.{Format}", "GET", Summary = "Gets subtitles in a specified format (vtt).")]
|
|
|
- public class GetSubtitle
|
|
|
- {
|
|
|
- /// <summary>
|
|
|
- /// Gets or sets the id.
|
|
|
- /// </summary>
|
|
|
- /// <value>The id.</value>
|
|
|
- [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
- public string Id { get; set; }
|
|
|
-
|
|
|
- [ApiMember(Name = "MediaSourceId", Description = "MediaSourceId", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
- public string MediaSourceId { get; set; }
|
|
|
-
|
|
|
- [ApiMember(Name = "Index", Description = "The subtitle stream index", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")]
|
|
|
- public int Index { get; set; }
|
|
|
-
|
|
|
- [ApiMember(Name = "Format", Description = "Format", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
- public string Format { get; set; }
|
|
|
-
|
|
|
- [ApiMember(Name = "StartPositionTicks", Description = "StartPositionTicks", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
- public long StartPositionTicks { get; set; }
|
|
|
- }
|
|
|
-
|
|
|
[Route("/Videos/{Id}/Subtitles/{Index}", "DELETE", Summary = "Deletes an external subtitle file")]
|
|
|
+ [Authenticated]
|
|
|
public class DeleteSubtitle
|
|
|
{
|
|
|
/// <summary>
|
|
@@ -54,6 +32,7 @@ namespace MediaBrowser.Api.Library
|
|
|
}
|
|
|
|
|
|
[Route("/Items/{Id}/RemoteSearch/Subtitles/{Language}", "GET")]
|
|
|
+ [Authenticated]
|
|
|
public class SearchRemoteSubtitles : IReturn<List<RemoteSubtitleInfo>>
|
|
|
{
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
@@ -64,6 +43,7 @@ namespace MediaBrowser.Api.Library
|
|
|
}
|
|
|
|
|
|
[Route("/Items/{Id}/RemoteSearch/Subtitles/Providers", "GET")]
|
|
|
+ [Authenticated]
|
|
|
public class GetSubtitleProviders : IReturn<List<SubtitleProviderInfo>>
|
|
|
{
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
@@ -71,6 +51,7 @@ namespace MediaBrowser.Api.Library
|
|
|
}
|
|
|
|
|
|
[Route("/Items/{Id}/RemoteSearch/Subtitles/{SubtitleId}", "POST")]
|
|
|
+ [Authenticated]
|
|
|
public class DownloadRemoteSubtitles : IReturnVoid
|
|
|
{
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
|
@@ -81,13 +62,36 @@ namespace MediaBrowser.Api.Library
|
|
|
}
|
|
|
|
|
|
[Route("/Providers/Subtitles/Subtitles/{Id}", "GET")]
|
|
|
+ [Authenticated]
|
|
|
public class GetRemoteSubtitles : IReturnVoid
|
|
|
{
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
public string Id { get; set; }
|
|
|
}
|
|
|
|
|
|
- [Authenticated]
|
|
|
+ [Route("/Videos/{Id}/{MediaSourceId}/Subtitles/{Index}/Stream.{Format}", "GET", Summary = "Gets subtitles in a specified format (vtt).")]
|
|
|
+ public class GetSubtitle
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// Gets or sets the id.
|
|
|
+ /// </summary>
|
|
|
+ /// <value>The id.</value>
|
|
|
+ [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
+ public string Id { get; set; }
|
|
|
+
|
|
|
+ [ApiMember(Name = "MediaSourceId", Description = "MediaSourceId", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
+ public string MediaSourceId { get; set; }
|
|
|
+
|
|
|
+ [ApiMember(Name = "Index", Description = "The subtitle stream index", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")]
|
|
|
+ public int Index { get; set; }
|
|
|
+
|
|
|
+ [ApiMember(Name = "Format", Description = "Format", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
+ public string Format { get; set; }
|
|
|
+
|
|
|
+ [ApiMember(Name = "StartPositionTicks", Description = "StartPositionTicks", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
+ public long StartPositionTicks { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
public class SubtitleService : BaseApiService
|
|
|
{
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
@@ -101,14 +105,6 @@ namespace MediaBrowser.Api.Library
|
|
|
_subtitleEncoder = subtitleEncoder;
|
|
|
}
|
|
|
|
|
|
- public object Get(SearchRemoteSubtitles request)
|
|
|
- {
|
|
|
- var video = (Video)_libraryManager.GetItemById(request.Id);
|
|
|
-
|
|
|
- var response = _subtitleManager.SearchSubtitles(video, request.Language, CancellationToken.None).Result;
|
|
|
-
|
|
|
- return ToOptimizedResult(response);
|
|
|
- }
|
|
|
public object Get(GetSubtitle request)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(request.Format))
|
|
@@ -131,14 +127,23 @@ namespace MediaBrowser.Api.Library
|
|
|
|
|
|
private async Task<Stream> GetSubtitles(GetSubtitle request)
|
|
|
{
|
|
|
- return await _subtitleEncoder.GetSubtitles(request.Id,
|
|
|
- request.MediaSourceId,
|
|
|
- request.Index,
|
|
|
+ return await _subtitleEncoder.GetSubtitles(request.Id,
|
|
|
+ request.MediaSourceId,
|
|
|
+ request.Index,
|
|
|
request.Format,
|
|
|
request.StartPositionTicks,
|
|
|
CancellationToken.None).ConfigureAwait(false);
|
|
|
}
|
|
|
|
|
|
+ public object Get(SearchRemoteSubtitles request)
|
|
|
+ {
|
|
|
+ var video = (Video)_libraryManager.GetItemById(request.Id);
|
|
|
+
|
|
|
+ var response = _subtitleManager.SearchSubtitles(video, request.Language, CancellationToken.None).Result;
|
|
|
+
|
|
|
+ return ToOptimizedResult(response);
|
|
|
+ }
|
|
|
+
|
|
|
public void Delete(DeleteSubtitle request)
|
|
|
{
|
|
|
var task = _subtitleManager.DeleteSubtitles(request.Id, request.Index);
|