mirror of https://github.com/jellyfin/jellyfin.git
added GetTempFileResponse
This commit is contained in:
parent
cf057c5b27
commit
7e5bdc837a
|
@ -374,6 +374,13 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
/// <exception cref="HttpException"></exception>
|
||||
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
|
||||
public async Task<string> GetTempFile(HttpRequestOptions options)
|
||||
{
|
||||
var response = await GetTempFileResponse(options).ConfigureAwait(false);
|
||||
|
||||
return response.TempFilePath;
|
||||
}
|
||||
|
||||
public async Task<HttpResponseInfo> GetTempFileResponse(HttpRequestOptions options)
|
||||
{
|
||||
ValidateParams(options.Url, options.CancellationToken);
|
||||
|
||||
|
@ -433,13 +440,20 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
|
||||
options.Progress.Report(100);
|
||||
|
||||
options.CancellationToken.ThrowIfCancellationRequested();
|
||||
return new HttpResponseInfo
|
||||
{
|
||||
TempFilePath = tempFile,
|
||||
|
||||
StatusCode = response.StatusCode,
|
||||
|
||||
ContentType = response.Content.Headers.ContentType.MediaType
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleTempFileException(ex, options, tempFile);
|
||||
throw GetTempFileException(ex, options, tempFile);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -448,8 +462,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
options.ResourcePool.Release();
|
||||
}
|
||||
}
|
||||
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -501,7 +513,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
/// <param name="tempFile">The temp file.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="HttpException"></exception>
|
||||
private void HandleTempFileException(Exception ex, HttpRequestOptions options, string tempFile)
|
||||
private Exception GetTempFileException(Exception ex, HttpRequestOptions options, string tempFile)
|
||||
{
|
||||
var operationCanceledException = ex as OperationCanceledException;
|
||||
|
||||
|
@ -513,7 +525,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
File.Delete(tempFile);
|
||||
}
|
||||
|
||||
throw GetCancellationException(options.Url, options.CancellationToken, operationCanceledException);
|
||||
return GetCancellationException(options.Url, options.CancellationToken, operationCanceledException);
|
||||
}
|
||||
|
||||
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
||||
|
@ -528,10 +540,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
|
||||
if (httpRequestException != null)
|
||||
{
|
||||
throw new HttpException(ex.Message, ex);
|
||||
return new HttpException(ex.Message, ex);
|
||||
}
|
||||
|
||||
throw ex;
|
||||
return ex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -25,5 +25,11 @@ namespace MediaBrowser.Common.Net
|
|||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
public HttpStatusCode StatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the temp file path.
|
||||
/// </summary>
|
||||
/// <value>The temp file path.</value>
|
||||
public string TempFilePath { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,5 +72,7 @@ namespace MediaBrowser.Common.Net
|
|||
/// <exception cref="System.ArgumentNullException">progress</exception>
|
||||
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
|
||||
Task<string> GetTempFile(HttpRequestOptions options);
|
||||
|
||||
Task<HttpResponseInfo> GetTempFileResponse(HttpRequestOptions options);
|
||||
}
|
||||
}
|
|
@ -445,6 +445,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
break;
|
||||
}
|
||||
|
||||
case "BirthDate":
|
||||
case "PremiereDate":
|
||||
case "FirstAired":
|
||||
{
|
||||
|
|
|
@ -198,9 +198,16 @@ namespace MediaBrowser.Providers.Savers
|
|||
builder.Append("<SortTitle>" + SecurityElement.Escape(item.ForcedSortName) + "</SortTitle>");
|
||||
}
|
||||
|
||||
if (item.PremiereDate.HasValue && !(item is Episode))
|
||||
if (item.PremiereDate.HasValue)
|
||||
{
|
||||
builder.Append("<PremiereDate>" + SecurityElement.Escape(item.PremiereDate.Value.ToString("yyyy-MM-dd")) + "</PremiereDate>");
|
||||
if (item is Person)
|
||||
{
|
||||
builder.Append("<BirthDate>" + SecurityElement.Escape(item.PremiereDate.Value.ToString("yyyy-MM-dd")) + "</BirthDate>");
|
||||
}
|
||||
else if (!(item is Episode))
|
||||
{
|
||||
builder.Append("<PremiereDate>" + SecurityElement.Escape(item.PremiereDate.Value.ToString("yyyy-MM-dd")) + "</PremiereDate>");
|
||||
}
|
||||
}
|
||||
|
||||
if (item.RemoteTrailers.Count > 0)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common.Internal</id>
|
||||
<version>3.0.150</version>
|
||||
<version>3.0.151</version>
|
||||
<title>MediaBrowser.Common.Internal</title>
|
||||
<authors>Luke</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.150" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.151" />
|
||||
<dependency id="NLog" version="2.0.1.2" />
|
||||
<dependency id="ServiceStack.Text" version="3.9.45" />
|
||||
<dependency id="SimpleInjector" version="2.2.3" />
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common</id>
|
||||
<version>3.0.150</version>
|
||||
<version>3.0.151</version>
|
||||
<title>MediaBrowser.Common</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Server.Core</id>
|
||||
<version>3.0.150</version>
|
||||
<version>3.0.151</version>
|
||||
<title>Media Browser.Server.Core</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.150" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.151" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
|
Loading…
Reference in New Issue