aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/BaseApiService.cs10
-rw-r--r--MediaBrowser.Api/Library/LibraryService.cs84
-rw-r--r--MediaBrowser.Api/SearchService.cs2
-rw-r--r--MediaBrowser.Api/System/SystemService.cs5
-rw-r--r--MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs2
5 files changed, 55 insertions, 48 deletions
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs
index b43aed7bf..1a1d86362 100644
--- a/MediaBrowser.Api/BaseApiService.cs
+++ b/MediaBrowser.Api/BaseApiService.cs
@@ -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 },
diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs
index d71bf9a0e..26be9db83 100644
--- a/MediaBrowser.Api/Library/LibraryService.cs
+++ b/MediaBrowser.Api/Library/LibraryService.cs
@@ -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;
- }
-
- 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 !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(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);
diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.cs
index 15148d1c7..e9d339c6e 100644
--- a/MediaBrowser.Api/SearchService.cs
+++ b/MediaBrowser.Api/SearchService.cs
@@ -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)
{
diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs
index cfede6f69..c57cc93d5 100644
--- a/MediaBrowser.Api/System/SystemService.cs
+++ b/MediaBrowser.Api/System/SystemService.cs
@@ -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>
diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs
index eb2f5996e..f9f66f135 100644
--- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs
+++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs
@@ -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();
}