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