Implemented more suggestions

pull/2772/head
Patrick Barron 5 years ago
parent 47ba4a84cd
commit c9da49ebaa

@ -262,19 +262,23 @@ namespace MediaBrowser.Api
private T GetItemFromSlugName<T>(ILibraryManager libraryManager, string name, DtoOptions dtoOptions)
where T : BaseItem, new()
{
var result = (libraryManager.GetItemList(new InternalItemsQuery
var result = libraryManager.GetItemList(new InternalItemsQuery
{
Name = name.Replace(BaseItem.SlugChar, '&'),
IncludeItemTypes = new[] { typeof(T).Name },
DtoOptions = dtoOptions
}).OfType<T>().FirstOrDefault() ?? libraryManager.GetItemList(new InternalItemsQuery
}).OfType<T>().FirstOrDefault();
result ??= libraryManager.GetItemList(new InternalItemsQuery
{
Name = name.Replace(BaseItem.SlugChar, '/'),
IncludeItemTypes = new[] { typeof(T).Name },
DtoOptions = dtoOptions
}).OfType<T>().FirstOrDefault()) ?? libraryManager.GetItemList(new InternalItemsQuery
}).OfType<T>().FirstOrDefault();
result ??= libraryManager.GetItemList(new InternalItemsQuery
{
Name = name.Replace(BaseItem.SlugChar, '?'),
IncludeItemTypes = new[] { typeof(T).Name },

@ -388,24 +388,14 @@ namespace MediaBrowser.Api.Library
{
if (string.Equals(name, "TheMovieDb", StringComparison.OrdinalIgnoreCase))
{
if (string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase)
return !(string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase)
|| string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase)
|| string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase))
{
return false;
}
return true;
|| string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase));
}
if (string.Equals(name, "TheTVDB", StringComparison.OrdinalIgnoreCase)
return string.Equals(name, "TheTVDB", StringComparison.OrdinalIgnoreCase)
|| string.Equals(name, "TheAudioDB", StringComparison.OrdinalIgnoreCase)
|| string.Equals(name, "MusicBrainz", StringComparison.OrdinalIgnoreCase))
{
return true;
}
return false;
|| string.Equals(name, "MusicBrainz", StringComparison.OrdinalIgnoreCase);
}
var metadataOptions = ServerConfigurationManager.Configuration.MetadataOptions
@ -422,27 +412,17 @@ namespace MediaBrowser.Api.Library
{
if (string.Equals(name, "TheMovieDb", StringComparison.OrdinalIgnoreCase))
{
if (string.Equals(type, "Series", StringComparison.OrdinalIgnoreCase)
|| string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase)
|| string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase)
|| string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase))
{
return false;
return !string.Equals(type, "Series", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase);
}
return true;
}
if (string.Equals(name, "TheTVDB", StringComparison.OrdinalIgnoreCase)
return string.Equals(name, "TheTVDB", StringComparison.OrdinalIgnoreCase)
|| string.Equals(name, "Screen Grabber", StringComparison.OrdinalIgnoreCase)
|| string.Equals(name, "TheAudioDB", StringComparison.OrdinalIgnoreCase)
|| string.Equals(name, "Emby Designs", StringComparison.OrdinalIgnoreCase)
|| string.Equals(name, "Image Extractor", StringComparison.OrdinalIgnoreCase))
{
return true;
}
return false;
|| string.Equals(name, "Image Extractor", StringComparison.OrdinalIgnoreCase);
}
var metadataOptions = ServerConfigurationManager.Configuration.MetadataOptions
@ -1034,12 +1014,23 @@ namespace MediaBrowser.Api.Library
throw new ResourceNotFoundException("Item not found.");
}
IEnumerable<BaseItem> themeItems = item.GetThemeSongs();
IEnumerable<BaseItem> themeItems;
while (!themeItems.Any() && request.InheritFromParent && item.GetParent() != null)
while (true)
{
item = item.GetParent();
themeItems = item.GetThemeSongs();
if (themeItems.Any() || !request.InheritFromParent)
{
break;
}
var parent = item.GetParent();
if (parent == null)
{
break;
}
item = parent;
}
var dtoOptions = GetDtoOptions(_authContext, request);
@ -1080,12 +1071,23 @@ namespace MediaBrowser.Api.Library
throw new ResourceNotFoundException("Item not found.");
}
IEnumerable<BaseItem> themeItems = item.GetThemeVideos();
IEnumerable<BaseItem> themeItems;
while (!themeItems.Any() && request.InheritFromParent && item.GetParent() != null)
while (true)
{
item = item.GetParent();
themeItems = item.GetThemeVideos();
if (themeItems.Any() || !request.InheritFromParent)
{
break;
}
var parent = item.GetParent();
if (parent == null)
{
break;
}
item = parent;
}
var dtoOptions = GetDtoOptions(_authContext, request);

@ -168,8 +168,9 @@ namespace MediaBrowser.Api.System
.First(i => string.Equals(i.Name, request.Name, StringComparison.OrdinalIgnoreCase));
// For older files, assume fully static
return ResultFactory.GetStaticFileResult(Request, file.FullName,
file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1) ? FileShare.Read : FileShare.ReadWrite);
var fileShare = file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1) ? FileShare.Read : FileShare.ReadWrite;
return ResultFactory.GetStaticFileResult(Request, file.FullName, fileShare);
}
/// <summary>

@ -425,7 +425,7 @@ namespace MediaBrowser.Api.UserLibrary
var val = ImageTypes;
return string.IsNullOrEmpty(val)
? new ImageType[] { }
? Array.Empty<ImageType>()
: val.Split(',').Select(v => Enum.Parse<ImageType>(v, true)).ToArray();
}

Loading…
Cancel
Save