be more tolerant of media folder names with invalid url chars

pull/702/head
Luke Pulverenti 11 years ago
parent 3488cfecbd
commit 30b29f63c4

@ -28,8 +28,8 @@ namespace MediaBrowser.Api.Library
public string UserId { get; set; } public string UserId { get; set; }
} }
[Route("/Library/VirtualFolders/{Name}", "POST")] [Route("/Library/VirtualFolders", "POST")]
[Route("/Users/{UserId}/VirtualFolders/{Name}", "POST")] [Route("/Users/{UserId}/VirtualFolders", "POST")]
public class AddVirtualFolder : IReturnVoid public class AddVirtualFolder : IReturnVoid
{ {
/// <summary> /// <summary>
@ -57,8 +57,8 @@ namespace MediaBrowser.Api.Library
public bool RefreshLibrary { get; set; } public bool RefreshLibrary { get; set; }
} }
[Route("/Library/VirtualFolders/{Name}", "DELETE")] [Route("/Library/VirtualFolders", "DELETE")]
[Route("/Users/{UserId}/VirtualFolders/{Name}", "DELETE")] [Route("/Users/{UserId}/VirtualFolders", "DELETE")]
public class RemoveVirtualFolder : IReturnVoid public class RemoveVirtualFolder : IReturnVoid
{ {
/// <summary> /// <summary>
@ -80,8 +80,8 @@ namespace MediaBrowser.Api.Library
public bool RefreshLibrary { get; set; } public bool RefreshLibrary { get; set; }
} }
[Route("/Library/VirtualFolders/{Name}/Name", "POST")] [Route("/Library/VirtualFolders/Name", "POST")]
[Route("/Users/{UserId}/VirtualFolders/{Name}/Name", "POST")] [Route("/Users/{UserId}/VirtualFolders/Name", "POST")]
public class RenameVirtualFolder : IReturnVoid public class RenameVirtualFolder : IReturnVoid
{ {
/// <summary> /// <summary>
@ -109,8 +109,8 @@ namespace MediaBrowser.Api.Library
public bool RefreshLibrary { get; set; } public bool RefreshLibrary { get; set; }
} }
[Route("/Library/VirtualFolders/{Name}/Paths", "POST")] [Route("/Library/VirtualFolders/Paths", "POST")]
[Route("/Users/{UserId}/VirtualFolders/{Name}/Paths", "POST")] [Route("/Users/{UserId}/VirtualFolders/Paths", "POST")]
public class AddMediaPath : IReturnVoid public class AddMediaPath : IReturnVoid
{ {
/// <summary> /// <summary>
@ -138,8 +138,8 @@ namespace MediaBrowser.Api.Library
public bool RefreshLibrary { get; set; } public bool RefreshLibrary { get; set; }
} }
[Route("/Library/VirtualFolders/{Name}/Paths", "DELETE")] [Route("/Library/VirtualFolders/Paths", "DELETE")]
[Route("/Users/{UserId}/VirtualFolders/{Name}/Paths", "DELETE")] [Route("/Users/{UserId}/VirtualFolders/Paths", "DELETE")]
public class RemoveMediaPath : IReturnVoid public class RemoveMediaPath : IReturnVoid
{ {
/// <summary> /// <summary>
@ -243,6 +243,11 @@ namespace MediaBrowser.Api.Library
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Post(AddVirtualFolder request) public void Post(AddVirtualFolder request)
{ {
if (string.IsNullOrWhiteSpace(request.Name))
{
throw new ArgumentNullException("request");
}
var name = _fileSystem.GetValidFilename(request.Name); var name = _fileSystem.GetValidFilename(request.Name);
string rootFolderPath; string rootFolderPath;
@ -307,6 +312,16 @@ namespace MediaBrowser.Api.Library
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Post(RenameVirtualFolder request) public void Post(RenameVirtualFolder request)
{ {
if (string.IsNullOrWhiteSpace(request.Name))
{
throw new ArgumentNullException("request");
}
if (string.IsNullOrWhiteSpace(request.NewName))
{
throw new ArgumentNullException("request");
}
string rootFolderPath; string rootFolderPath;
if (string.IsNullOrEmpty(request.UserId)) if (string.IsNullOrEmpty(request.UserId))
@ -380,6 +395,11 @@ namespace MediaBrowser.Api.Library
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Delete(RemoveVirtualFolder request) public void Delete(RemoveVirtualFolder request)
{ {
if (string.IsNullOrWhiteSpace(request.Name))
{
throw new ArgumentNullException("request");
}
string rootFolderPath; string rootFolderPath;
if (string.IsNullOrEmpty(request.UserId)) if (string.IsNullOrEmpty(request.UserId))
@ -435,6 +455,11 @@ namespace MediaBrowser.Api.Library
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Post(AddMediaPath request) public void Post(AddMediaPath request)
{ {
if (string.IsNullOrWhiteSpace(request.Name))
{
throw new ArgumentNullException("request");
}
_directoryWatchers.Stop(); _directoryWatchers.Stop();
try try
@ -476,6 +501,11 @@ namespace MediaBrowser.Api.Library
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Delete(RemoveMediaPath request) public void Delete(RemoveMediaPath request)
{ {
if (string.IsNullOrWhiteSpace(request.Name))
{
throw new ArgumentNullException("request");
}
_directoryWatchers.Stop(); _directoryWatchers.Stop();
try try

@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;

@ -168,7 +168,7 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Studios\backdrops.txt" /> <EmbeddedResource Include="Studios\thumbs.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Studios\posters.txt" /> <EmbeddedResource Include="Studios\posters.txt" />

@ -49,7 +49,7 @@ namespace MediaBrowser.Providers.Studios
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo) protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{ {
if (!string.IsNullOrEmpty(item.PrimaryImagePath) && item.BackdropImagePaths.Count == 0) if (item.HasImage(ImageType.Primary) && item.HasImage(ImageType.Thumb))
{ {
return false; return false;
} }
@ -75,12 +75,15 @@ namespace MediaBrowser.Providers.Studios
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken) public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(item.PrimaryImagePath) || item.BackdropImagePaths.Count == 0) if (item.HasImage(ImageType.Primary) && item.HasImage(ImageType.Thumb))
{ {
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
}
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, StudiosManualImageProvider.ProviderName).ConfigureAwait(false); var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, StudiosManualImageProvider.ProviderName).ConfigureAwait(false);
await DownloadImages(item, images.ToList(), cancellationToken).ConfigureAwait(false); await DownloadImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo); SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true; return true;
@ -96,6 +99,12 @@ namespace MediaBrowser.Providers.Studios
{ {
await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false); await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false);
} }
cancellationToken.ThrowIfCancellationRequested();
if (!item.HasImage(ImageType.Thumb))
{
await SaveImage(item, images, ImageType.Thumb, cancellationToken).ConfigureAwait(false);
}
} }
if (!item.LockedFields.Contains(MetadataFields.Backdrops)) if (!item.LockedFields.Contains(MetadataFields.Backdrops))

@ -51,7 +51,7 @@ namespace MediaBrowser.Providers.Studios
if (backdrops) if (backdrops)
{ {
//list.Add(GetImage(item, "backdrops.txt", ImageType.Backdrop, "backdrop")); list.Add(GetImage(item, "thumbs.txt", ImageType.Thumb, "thumb"));
} }
return Task.FromResult(list.Where(i => i != null)); return Task.FromResult(list.Where(i => i != null));

@ -1328,10 +1328,9 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders"; var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders";
url += "/" + name;
url = self.getUrl(url, { url = self.getUrl(url, {
refreshLibrary: refreshLibrary ? true : false refreshLibrary: refreshLibrary ? true : false,
name: name
}); });
return self.ajax({ return self.ajax({
@ -1357,10 +1356,10 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
} }
options.refreshLibrary = refreshLibrary ? true : false; options.refreshLibrary = refreshLibrary ? true : false;
options.name = name;
var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders"; var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders";
url += "/" + name;
url = self.getUrl(url, options); url = self.getUrl(url, options);
return self.ajax({ return self.ajax({
@ -1381,11 +1380,12 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders"; var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders";
url += "/" + name + "/Name"; url += "/Name";
url = self.getUrl(url, { url = self.getUrl(url, {
refreshLibrary: refreshLibrary ? true : false, refreshLibrary: refreshLibrary ? true : false,
newName: newName newName: newName,
name: name
}); });
return self.ajax({ return self.ajax({
@ -1410,11 +1410,12 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders"; var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders";
url += "/" + virtualFolderName + "/Paths"; url += "/Paths";
url = self.getUrl(url, { url = self.getUrl(url, {
refreshLibrary: refreshLibrary ? true : false, refreshLibrary: refreshLibrary ? true : false,
path: mediaPath path: mediaPath,
name: virtualFolderName
}); });
return self.ajax({ return self.ajax({
@ -1439,11 +1440,12 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders"; var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders";
url += "/" + virtualFolderName + "/Paths"; url += "/Paths";
url = self.getUrl(url, { url = self.getUrl(url, {
refreshLibrary: refreshLibrary ? true : false, refreshLibrary: refreshLibrary ? true : false,
path: mediaPath path: mediaPath,
name: virtualFolderName
}); });
return self.ajax({ return self.ajax({

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.212" targetFramework="net45" /> <package id="MediaBrowser.ApiClient.Javascript" version="3.0.213" targetFramework="net45" />
</packages> </packages>
Loading…
Cancel
Save