Implemented more suggestions
This commit is contained in:
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)
|
||||
|| string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
if (string.Equals(name, "TheTVDB", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(name, "TheAudioDB", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(name, "MusicBrainz", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return string.Equals(name, "TheTVDB", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(name, "TheAudioDB", StringComparison.OrdinalIgnoreCase)
|
||||
|| 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 true;
|
||||
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);
|
||||
}
|
||||
|
||||
if (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;
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -310,7 +310,7 @@ namespace MediaBrowser.Api
|
|||
private void SetBackdropImageInfo(SearchHint hint, BaseItem item)
|
||||
{
|
||||
var itemWithImage = (item.HasImage(ImageType.Backdrop) ? item : null)
|
||||
?? GetParentWithImage<BaseItem>(item, ImageType.Backdrop);
|
||||
?? GetParentWithImage<BaseItem>(item, ImageType.Backdrop);
|
||||
|
||||
if (itemWithImage != null)
|
||||
{
|
||||
|
|
|
@ -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…
Reference in New Issue
Block a user