mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update playlist drag and drop
This commit is contained in:
parent
6c3355b26f
commit
f4ad65196a
@ -356,7 +356,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
|
|
||||||
private async Task CacheResponse(HttpResponseInfo response, string responseCachePath)
|
private async Task CacheResponse(HttpResponseInfo response, string responseCachePath)
|
||||||
{
|
{
|
||||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(responseCachePath));
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(responseCachePath));
|
||||||
|
|
||||||
using (var responseStream = response.Content)
|
using (var responseStream = response.Content)
|
||||||
{
|
{
|
||||||
@ -465,20 +465,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
}
|
}
|
||||||
catch (OperationCanceledException ex)
|
catch (OperationCanceledException ex)
|
||||||
{
|
{
|
||||||
var exception = GetCancellationException(options, options.CancellationToken, ex);
|
throw GetCancellationException(options, client, options.CancellationToken, ex);
|
||||||
|
|
||||||
var httpException = exception as HttpException;
|
|
||||||
|
|
||||||
if (httpException != null && httpException.IsTimedOut)
|
|
||||||
{
|
|
||||||
client.LastTimeout = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw exception;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw GetException(ex, options);
|
throw GetException(ex, options, client);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -489,30 +480,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the exception.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ex">The ex.</param>
|
|
||||||
/// <param name="options">The options.</param>
|
|
||||||
/// <returns>HttpException.</returns>
|
|
||||||
private HttpException GetException(WebException ex, HttpRequestOptions options)
|
|
||||||
{
|
|
||||||
if (options.LogErrors)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
var exception = new HttpException(ex.Message, ex);
|
|
||||||
|
|
||||||
var response = ex.Response as HttpWebResponse;
|
|
||||||
if (response != null)
|
|
||||||
{
|
|
||||||
exception.StatusCode = response.StatusCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
return exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HttpResponseInfo GetResponseInfo(HttpWebResponse httpResponse, Stream content, long? contentLength, IDisposable disposable)
|
private HttpResponseInfo GetResponseInfo(HttpWebResponse httpResponse, Stream content, long? contentLength, IDisposable disposable)
|
||||||
{
|
{
|
||||||
return new HttpResponseInfo(disposable)
|
return new HttpResponseInfo(disposable)
|
||||||
@ -603,7 +570,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
{
|
{
|
||||||
ValidateParams(options);
|
ValidateParams(options);
|
||||||
|
|
||||||
_fileSystem.CreateDirectory(_appPaths.TempDirectory);
|
_fileSystem.CreateDirectory(_appPaths.TempDirectory);
|
||||||
|
|
||||||
var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".tmp");
|
var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".tmp");
|
||||||
|
|
||||||
@ -628,6 +595,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
_logger.Info("HttpClientManager.GetTempFileResponse url: {0}", options.Url);
|
_logger.Info("HttpClientManager.GetTempFileResponse url: {0}", options.Url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
options.CancellationToken.ThrowIfCancellationRequested();
|
options.CancellationToken.ThrowIfCancellationRequested();
|
||||||
@ -636,7 +605,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
{
|
{
|
||||||
var httpResponse = (HttpWebResponse)response;
|
var httpResponse = (HttpWebResponse)response;
|
||||||
|
|
||||||
var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression);
|
|
||||||
EnsureSuccessStatusCode(client, httpResponse, options);
|
EnsureSuccessStatusCode(client, httpResponse, options);
|
||||||
|
|
||||||
options.CancellationToken.ThrowIfCancellationRequested();
|
options.CancellationToken.ThrowIfCancellationRequested();
|
||||||
@ -673,7 +641,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
DeleteTempFile(tempFile);
|
DeleteTempFile(tempFile);
|
||||||
throw GetException(ex, options);
|
throw GetException(ex, options, client);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -698,14 +666,37 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
|
|
||||||
protected static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
protected static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
private Exception GetException(Exception ex, HttpRequestOptions options)
|
private Exception GetException(Exception ex, HttpRequestOptions options, HttpClientInfo client)
|
||||||
{
|
{
|
||||||
|
if (ex is HttpException)
|
||||||
|
{
|
||||||
|
return ex;
|
||||||
|
}
|
||||||
|
|
||||||
var webException = ex as WebException
|
var webException = ex as WebException
|
||||||
?? ex.InnerException as WebException;
|
?? ex.InnerException as WebException;
|
||||||
|
|
||||||
if (webException != null)
|
if (webException != null)
|
||||||
{
|
{
|
||||||
return GetException(webException, options);
|
if (options.LogErrors)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
var exception = new HttpException(ex.Message, ex);
|
||||||
|
|
||||||
|
var response = webException.Response as HttpWebResponse;
|
||||||
|
if (response != null)
|
||||||
|
{
|
||||||
|
exception.StatusCode = response.StatusCode;
|
||||||
|
|
||||||
|
if ((int)response.StatusCode == 429)
|
||||||
|
{
|
||||||
|
client.LastTimeout = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
var operationCanceledException = ex as OperationCanceledException
|
var operationCanceledException = ex as OperationCanceledException
|
||||||
@ -713,7 +704,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
|
|
||||||
if (operationCanceledException != null)
|
if (operationCanceledException != null)
|
||||||
{
|
{
|
||||||
return GetCancellationException(options, options.CancellationToken, operationCanceledException);
|
return GetCancellationException(options, client, options.CancellationToken, operationCanceledException);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.LogErrors)
|
if (options.LogErrors)
|
||||||
@ -792,10 +783,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
/// Throws the cancellation exception.
|
/// Throws the cancellation exception.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">The options.</param>
|
/// <param name="options">The options.</param>
|
||||||
|
/// <param name="client">The client.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <param name="exception">The exception.</param>
|
/// <param name="exception">The exception.</param>
|
||||||
/// <returns>Exception.</returns>
|
/// <returns>Exception.</returns>
|
||||||
private Exception GetCancellationException(HttpRequestOptions options, CancellationToken cancellationToken, OperationCanceledException exception)
|
private Exception GetCancellationException(HttpRequestOptions options, HttpClientInfo client, CancellationToken cancellationToken, OperationCanceledException exception)
|
||||||
{
|
{
|
||||||
// If the HttpClient's timeout is reached, it will cancel the Task internally
|
// If the HttpClient's timeout is reached, it will cancel the Task internally
|
||||||
if (!cancellationToken.IsCancellationRequested)
|
if (!cancellationToken.IsCancellationRequested)
|
||||||
@ -807,6 +799,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
_logger.Error(msg);
|
_logger.Error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.LastTimeout = DateTime.UtcNow;
|
||||||
|
|
||||||
// Throw an HttpException so that the caller doesn't think it was cancelled by user code
|
// Throw an HttpException so that the caller doesn't think it was cancelled by user code
|
||||||
return new HttpException(msg, exception)
|
return new HttpException(msg, exception)
|
||||||
{
|
{
|
||||||
@ -825,15 +819,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
|
|
||||||
if (!isSuccessful)
|
if (!isSuccessful)
|
||||||
{
|
{
|
||||||
if ((int) statusCode == 429)
|
|
||||||
{
|
|
||||||
throw new HttpException(response.StatusDescription)
|
|
||||||
{
|
|
||||||
IsTimedOut = true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (statusCode == HttpStatusCode.RequestEntityTooLarge)
|
|
||||||
if (options.LogErrorResponseBody)
|
if (options.LogErrorResponseBody)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -22,5 +23,14 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The date modified.</value>
|
/// <value>The date modified.</value>
|
||||||
public DateTime DateModified { get; set; }
|
public DateTime DateModified { get; set; }
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool IsLocalFile
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1748,8 +1748,6 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = imageInfo.Path;
|
|
||||||
|
|
||||||
ImageSize size;
|
ImageSize size;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -248,6 +248,11 @@ namespace MediaBrowser.Server.Implementations.Photos
|
|||||||
|
|
||||||
if (image != null)
|
if (image != null)
|
||||||
{
|
{
|
||||||
|
if (!image.IsLocalFile)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!FileSystem.ContainsSubPath(item.GetInternalMetadataPath(), image.Path))
|
if (!FileSystem.ContainsSubPath(item.GetInternalMetadataPath(), image.Path))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -269,6 +274,11 @@ namespace MediaBrowser.Server.Implementations.Photos
|
|||||||
|
|
||||||
if (image != null)
|
if (image != null)
|
||||||
{
|
{
|
||||||
|
if (!image.IsLocalFile)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!FileSystem.ContainsSubPath(item.GetInternalMetadataPath(), image.Path))
|
if (!FileSystem.ContainsSubPath(item.GetInternalMetadataPath(), image.Path))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -111,7 +111,7 @@ namespace MediaBrowser.Server.Implementations.Playlists
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_fileSystem.CreateDirectory(path);
|
_fileSystem.CreateDirectory(path);
|
||||||
|
|
||||||
var playlist = new Playlist
|
var playlist = new Playlist
|
||||||
{
|
{
|
||||||
@ -151,7 +151,7 @@ namespace MediaBrowser.Server.Implementations.Playlists
|
|||||||
|
|
||||||
private string GetTargetPath(string path)
|
private string GetTargetPath(string path)
|
||||||
{
|
{
|
||||||
while (_fileSystem.DirectoryExists(path))
|
while (_fileSystem.DirectoryExists(path))
|
||||||
{
|
{
|
||||||
path += "1";
|
path += "1";
|
||||||
}
|
}
|
||||||
@ -243,6 +243,16 @@ namespace MediaBrowser.Server.Implementations.Playlists
|
|||||||
|
|
||||||
var oldIndex = children.FindIndex(i => string.Equals(entryId, i.Item1.Id, StringComparison.OrdinalIgnoreCase));
|
var oldIndex = children.FindIndex(i => string.Equals(entryId, i.Item1.Id, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (oldIndex == newIndex)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newIndex > oldIndex)
|
||||||
|
{
|
||||||
|
newIndex--;
|
||||||
|
}
|
||||||
|
|
||||||
var item = playlist.LinkedChildren[oldIndex];
|
var item = playlist.LinkedChildren[oldIndex];
|
||||||
|
|
||||||
playlist.LinkedChildren.Remove(item);
|
playlist.LinkedChildren.Remove(item);
|
||||||
|
@ -893,7 +893,10 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||||||
|
|
||||||
foreach (var backdrop in item.GetImages(ImageType.Backdrop))
|
foreach (var backdrop in item.GetImages(ImageType.Backdrop))
|
||||||
{
|
{
|
||||||
writer.WriteElementString("fanart", GetPathToSave(backdrop.Path, libraryManager, config));
|
if (backdrop.IsLocalFile)
|
||||||
|
{
|
||||||
|
writer.WriteElementString("fanart", GetPathToSave(backdrop.Path, libraryManager, config));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user