update SubtitleService

This commit is contained in:
Luke Pulverenti 2016-10-31 16:00:26 -04:00
parent 1e238c70bc
commit ed1f2a8a0c
3 changed files with 5 additions and 11 deletions

View File

@ -215,9 +215,9 @@ namespace MediaBrowser.Api.Subtitles
return await ResultFactory.GetStaticFileResult(Request, subtitleStream.Path).ConfigureAwait(false); return await ResultFactory.GetStaticFileResult(Request, subtitleStream.Path).ConfigureAwait(false);
} }
using (var stream = await GetSubtitles(request).ConfigureAwait(false))
{
if (string.Equals(request.Format, "vtt", StringComparison.OrdinalIgnoreCase) && request.AddVttTimeMap) if (string.Equals(request.Format, "vtt", StringComparison.OrdinalIgnoreCase) && request.AddVttTimeMap)
{
using (var stream = await GetSubtitles(request).ConfigureAwait(false))
{ {
using (var reader = new StreamReader(stream)) using (var reader = new StreamReader(stream))
{ {
@ -228,8 +228,9 @@ namespace MediaBrowser.Api.Subtitles
return ResultFactory.GetResult(text, MimeTypes.GetMimeType("file." + request.Format)); return ResultFactory.GetResult(text, MimeTypes.GetMimeType("file." + request.Format));
} }
} }
return ResultFactory.GetResult(stream, MimeTypes.GetMimeType("file." + request.Format));
} }
return ResultFactory.GetResult(await GetSubtitles(request).ConfigureAwait(false), MimeTypes.GetMimeType("file." + request.Format));
} }
private Task<Stream> GetSubtitles(GetSubtitle request) private Task<Stream> GetSubtitles(GetSubtitle request)

View File

@ -88,8 +88,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
Headers["Content-Length"] = source.Length.ToString(UsCulture); Headers["Content-Length"] = source.Length.ToString(UsCulture);
} }
private const int BufferSize = 81920;
public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken) public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
{ {
try try
@ -102,7 +100,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{ {
using (var src = SourceStream) using (var src = SourceStream)
{ {
await src.CopyToAsync(responseStream, BufferSize).ConfigureAwait(false); await src.CopyToAsync(responseStream).ConfigureAwait(false);
} }
} }
} }

View File

@ -79,7 +79,6 @@
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
@ -87,16 +86,12 @@
<Reference Include="System.Net" /> <Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" /> <Reference Include="System.Security" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" /> <Reference Include="System.Transactions" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="ServiceStack"> <Reference Include="ServiceStack">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath>
</Reference> </Reference>
<Reference Include="ServiceStack.Common">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Common.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces"> <Reference Include="ServiceStack.Interfaces">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath>
</Reference> </Reference>