From add0a2088de154137cf547f84c85f59a78e442d8 Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Sun, 5 Apr 2020 14:44:14 -0400 Subject: [PATCH] Simplified Conditionals and returns --- MediaBrowser.Api/ApiEntryPoint.cs | 22 +- MediaBrowser.Api/BaseApiService.cs | 24 +- MediaBrowser.Api/ChannelService.cs | 18 +- MediaBrowser.Api/Devices/DeviceService.cs | 16 +- MediaBrowser.Api/EnvironmentService.cs | 7 +- MediaBrowser.Api/Library/LibraryService.cs | 65 ++-- .../Playback/BaseStreamingService.cs | 342 +++++++++--------- MediaBrowser.Api/Playback/MediaInfoService.cs | 12 +- MediaBrowser.Api/SearchService.cs | 77 ++-- MediaBrowser.Api/System/SystemService.cs | 8 +- .../UserLibrary/ArtistsService.cs | 7 +- .../UserLibrary/BaseItemsRequest.cs | 29 +- 12 files changed, 277 insertions(+), 350 deletions(-) diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 2215bb5c40..61ad976ec3 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -86,12 +86,9 @@ namespace MediaBrowser.Api return Array.Empty(); } - if (removeEmpty) - { - return value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries); - } - - return value.Split(separator); + return removeEmpty + ? value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries) + : value.Split(separator); } public SemaphoreSlim GetTranscodingLock(string outputPath) @@ -487,16 +484,9 @@ namespace MediaBrowser.Api /// Task. internal Task KillTranscodingJobs(string deviceId, string playSessionId, Func deleteFiles) { - return KillTranscodingJobs(j => - { - if (!string.IsNullOrWhiteSpace(playSessionId)) - { - return string.Equals(playSessionId, j.PlaySessionId, StringComparison.OrdinalIgnoreCase); - } - - return string.Equals(deviceId, j.DeviceId, StringComparison.OrdinalIgnoreCase); - - }, deleteFiles); + return KillTranscodingJobs(j => !string.IsNullOrWhiteSpace(playSessionId) + ? string.Equals(playSessionId, j.PlaySessionId, StringComparison.OrdinalIgnoreCase) + : string.Equals(deviceId, j.DeviceId, StringComparison.OrdinalIgnoreCase), deleteFiles); } /// diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 0312cc57e2..b43aed7bfd 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -58,12 +58,9 @@ namespace MediaBrowser.Api public static string[] SplitValue(string value, char delim) { - if (value == null) - { - return Array.Empty(); - } - - return value.Split(new[] { delim }, StringSplitOptions.RemoveEmptyEntries); + return value == null + ? Array.Empty() + : value.Split(new[] { delim }, StringSplitOptions.RemoveEmptyEntries); } public static Guid[] GetGuids(string value) @@ -97,19 +94,10 @@ namespace MediaBrowser.Api var authenticatedUser = auth.User; // If they're going to update the record of another user, they must be an administrator - if (!userId.Equals(auth.UserId)) - { - if (!authenticatedUser.Policy.IsAdministrator) - { - throw new SecurityException("Unauthorized access."); - } - } - else if (restrictUserPreferences) + if ((!userId.Equals(auth.UserId) && !authenticatedUser.Policy.IsAdministrator) + || (restrictUserPreferences && !authenticatedUser.Policy.EnableUserPreferenceAccess)) { - if (!authenticatedUser.Policy.EnableUserPreferenceAccess) - { - throw new SecurityException("Unauthorized access."); - } + throw new SecurityException("Unauthorized access."); } } diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index 1d8ef81dfc..e43e34133c 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -116,12 +116,9 @@ namespace MediaBrowser.Api { var val = Filters; - if (string.IsNullOrEmpty(val)) - { - return new ItemFilter[] { }; - } - - return val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)); + return string.IsNullOrEmpty(val) + ? new ItemFilter[] { } + : val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)); } /// @@ -175,12 +172,9 @@ namespace MediaBrowser.Api { var val = Filters; - if (string.IsNullOrEmpty(val)) - { - return new ItemFilter[] { }; - } - - return val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)); + return string.IsNullOrEmpty(val) + ? new ItemFilter[] { } + : val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)); } } diff --git a/MediaBrowser.Api/Devices/DeviceService.cs b/MediaBrowser.Api/Devices/DeviceService.cs index 8b63decd22..7004a2559e 100644 --- a/MediaBrowser.Api/Devices/DeviceService.cs +++ b/MediaBrowser.Api/Devices/DeviceService.cs @@ -155,16 +155,14 @@ namespace MediaBrowser.Api.Devices Id = id }); } - else + + return _deviceManager.AcceptCameraUpload(deviceId, request.RequestStream, new LocalFileInfo { - return _deviceManager.AcceptCameraUpload(deviceId, request.RequestStream, new LocalFileInfo - { - MimeType = Request.ContentType, - Album = album, - Name = name, - Id = id - }); - } + MimeType = Request.ContentType, + Album = album, + Name = name, + Id = id + }); } } } diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index 36b03f09ce..d199ce1544 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -258,12 +258,7 @@ namespace MediaBrowser.Api return false; } - if (!request.IncludeDirectories && isDirectory) - { - return false; - } - - return true; + return request.IncludeDirectories || !isDirectory; }); return entries.Select(f => new FileSystemEntryInfo diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index b82247fc66..291242e458 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -348,28 +348,19 @@ namespace MediaBrowser.Api.Library private string[] GetRepresentativeItemTypes(string contentType) { - switch (contentType) + return contentType switch { - case CollectionType.BoxSets: - return new[] { "BoxSet" }; - case CollectionType.Playlists: - return new[] { "Playlist" }; - case CollectionType.Movies: - return new[] { "Movie" }; - case CollectionType.TvShows: - return new[] { "Series", "Season", "Episode" }; - case CollectionType.Books: - return new[] { "Book" }; - case CollectionType.Music: - return new[] { "MusicAlbum", "MusicArtist", "Audio", "MusicVideo" }; - case CollectionType.HomeVideos: - case CollectionType.Photos: - return new[] { "Video", "Photo" }; - case CollectionType.MusicVideos: - return new[] { "MusicVideo" }; - default: - return new[] { "Series", "Season", "Episode", "Movie" }; - } + CollectionType.BoxSets => new[] {"BoxSet"}, + CollectionType.Playlists => new[] {"Playlist"}, + CollectionType.Movies => new[] {"Movie"}, + CollectionType.TvShows => new[] {"Series", "Season", "Episode"}, + CollectionType.Books => new[] {"Book"}, + CollectionType.Music => new[] {"MusicAlbum", "MusicArtist", "Audio", "MusicVideo"}, + CollectionType.HomeVideos => new[] {"Video", "Photo"}, + CollectionType.Photos => new[] {"Video", "Photo"}, + CollectionType.MusicVideos => new[] {"MusicVideo"}, + _ => new[] {"Series", "Season", "Episode", "Movie"} + }; } private bool IsSaverEnabledByDefault(string name, string[] itemTypes, bool isNewLibrary) @@ -397,22 +388,18 @@ namespace MediaBrowser.Api.Library { if (string.Equals(name, "TheMovieDb", StringComparison.OrdinalIgnoreCase)) { + if (string.Equals(type, "Series", StringComparison.OrdinalIgnoreCase)) { return true; } - if (string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase)) - { - return false; - } - if (string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase)) - { - return false; - } - if (string.Equals(type, "MusicVideo", 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; } else if (string.Equals(name, "TheTVDB", StringComparison.OrdinalIgnoreCase)) @@ -439,12 +426,8 @@ namespace MediaBrowser.Api.Library .Where(i => string.Equals(i.ItemType, type, StringComparison.OrdinalIgnoreCase)) .ToArray(); - if (metadataOptions.Length == 0) - { - return true; - } - - return metadataOptions.Any(i => !i.DisabledMetadataFetchers.Contains(name, StringComparer.OrdinalIgnoreCase)); + return metadataOptions.Length == 0 + || metadataOptions.Any(i => !i.DisabledMetadataFetchers.Contains(name, StringComparer.OrdinalIgnoreCase)); } private bool IsImageFetcherEnabledByDefault(string name, string type, bool isNewLibrary) @@ -919,12 +902,10 @@ namespace MediaBrowser.Api.Library private BaseItem TranslateParentItem(BaseItem item, User user) { - if (item.GetParent() is AggregateFolder) - { - return _libraryManager.GetUserRootFolder().GetChildren(user, true).FirstOrDefault(i => i.PhysicalLocations.Contains(item.Path)); - } - - return item; + return item.GetParent() is AggregateFolder + ? _libraryManager.GetUserRootFolder().GetChildren(user, true) + .FirstOrDefault(i => i.PhysicalLocations.Contains(item.Path)) + : item; } /// diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6e923768a2..7c9e65fe7a 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -137,12 +137,7 @@ namespace MediaBrowser.Api.Playback var ext = outputFileExtension.ToLowerInvariant(); var folder = ServerConfigurationManager.GetTranscodePath(); - if (EnableOutputInSubFolder) - { - return Path.Combine(folder, filename, filename + ext); - } - - return Path.Combine(folder, filename + ext); + return EnableOutputInSubFolder ? Path.Combine(folder, filename, filename + ext) : Path.Combine(folder, filename + ext); } protected virtual string GetDefaultEncoderPreset() @@ -383,195 +378,215 @@ namespace MediaBrowser.Api.Playback continue; } - if (i == 0) - { - request.DeviceProfileId = val; - } - else if (i == 1) - { - request.DeviceId = val; - } - else if (i == 2) - { - request.MediaSourceId = val; - } - else if (i == 3) - { - request.Static = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); - } - else if (i == 4) + switch (i) { - if (videoRequest != null) + case 0: + request.DeviceProfileId = val; + break; + case 1: + request.DeviceId = val; + break; + case 2: + request.MediaSourceId = val; + break; + case 3: + request.Static = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + break; + case 4: { - videoRequest.VideoCodec = val; + if (videoRequest != null) + { + videoRequest.VideoCodec = val; + } + + break; } - } - else if (i == 5) - { - request.AudioCodec = val; - } - else if (i == 6) - { - if (videoRequest != null) + case 5: + request.AudioCodec = val; + break; + case 6: { - videoRequest.AudioStreamIndex = int.Parse(val, CultureInfo.InvariantCulture); + if (videoRequest != null) + { + videoRequest.AudioStreamIndex = int.Parse(val, CultureInfo.InvariantCulture); + } + + break; } - } - else if (i == 7) - { - if (videoRequest != null) + case 7: { - videoRequest.SubtitleStreamIndex = int.Parse(val, CultureInfo.InvariantCulture); + if (videoRequest != null) + { + videoRequest.SubtitleStreamIndex = int.Parse(val, CultureInfo.InvariantCulture); + } + + break; } - } - else if (i == 8) - { - if (videoRequest != null) + case 8: { - videoRequest.VideoBitRate = int.Parse(val, CultureInfo.InvariantCulture); + if (videoRequest != null) + { + videoRequest.VideoBitRate = int.Parse(val, CultureInfo.InvariantCulture); + } + + break; } - } - else if (i == 9) - { - request.AudioBitRate = int.Parse(val, CultureInfo.InvariantCulture); - } - else if (i == 10) - { - request.MaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture); - } - else if (i == 11) - { - if (videoRequest != null) + case 9: + request.AudioBitRate = int.Parse(val, CultureInfo.InvariantCulture); + break; + case 10: + request.MaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture); + break; + case 11: { - videoRequest.MaxFramerate = float.Parse(val, CultureInfo.InvariantCulture); + if (videoRequest != null) + { + videoRequest.MaxFramerate = float.Parse(val, CultureInfo.InvariantCulture); + } + + break; } - } - else if (i == 12) - { - if (videoRequest != null) + case 12: { - videoRequest.MaxWidth = int.Parse(val, CultureInfo.InvariantCulture); + if (videoRequest != null) + { + videoRequest.MaxWidth = int.Parse(val, CultureInfo.InvariantCulture); + } + + break; } - } - else if (i == 13) - { - if (videoRequest != null) + case 13: { - videoRequest.MaxHeight = int.Parse(val, CultureInfo.InvariantCulture); + if (videoRequest != null) + { + videoRequest.MaxHeight = int.Parse(val, CultureInfo.InvariantCulture); + } + + break; } - } - else if (i == 14) - { - request.StartTimeTicks = long.Parse(val, CultureInfo.InvariantCulture); - } - else if (i == 15) - { - if (videoRequest != null) + case 14: + request.StartTimeTicks = long.Parse(val, CultureInfo.InvariantCulture); + break; + case 15: { - videoRequest.Level = val; + if (videoRequest != null) + { + videoRequest.Level = val; + } + + break; } - } - else if (i == 16) - { - if (videoRequest != null) + case 16: { - videoRequest.MaxRefFrames = int.Parse(val, CultureInfo.InvariantCulture); + if (videoRequest != null) + { + videoRequest.MaxRefFrames = int.Parse(val, CultureInfo.InvariantCulture); + } + + break; } - } - else if (i == 17) - { - if (videoRequest != null) + case 17: { - videoRequest.MaxVideoBitDepth = int.Parse(val, CultureInfo.InvariantCulture); + if (videoRequest != null) + { + videoRequest.MaxVideoBitDepth = int.Parse(val, CultureInfo.InvariantCulture); + } + + break; } - } - else if (i == 18) - { - if (videoRequest != null) + case 18: { - videoRequest.Profile = val; + if (videoRequest != null) + { + videoRequest.Profile = val; + } + + break; } - } - else if (i == 19) - { - // cabac no longer used - } - else if (i == 20) - { - request.PlaySessionId = val; - } - else if (i == 21) - { - // api_key - } - else if (i == 22) - { - request.LiveStreamId = val; - } - else if (i == 23) - { - // Duplicating ItemId because of MediaMonkey - } - else if (i == 24) - { - if (videoRequest != null) + case 19: + // cabac no longer used + break; + case 20: + request.PlaySessionId = val; + break; + case 21: + // api_key + break; + case 22: + request.LiveStreamId = val; + break; + case 23: + // Duplicating ItemId because of MediaMonkey + break; + case 24: { - videoRequest.CopyTimestamps = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + if (videoRequest != null) + { + videoRequest.CopyTimestamps = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + } + + break; } - } - else if (i == 25) - { - if (!string.IsNullOrWhiteSpace(val) && videoRequest != null) + case 25: { - if (Enum.TryParse(val, out SubtitleDeliveryMethod method)) + if (!string.IsNullOrWhiteSpace(val) && videoRequest != null) { - videoRequest.SubtitleMethod = method; + if (Enum.TryParse(val, out SubtitleDeliveryMethod method)) + { + videoRequest.SubtitleMethod = method; + } } + + break; } - } - else if (i == 26) - { - request.TranscodingMaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture); - } - else if (i == 27) - { - if (videoRequest != null) + case 26: + request.TranscodingMaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture); + break; + case 27: { - videoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + if (videoRequest != null) + { + videoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + } + + break; } - } - else if (i == 28) - { - request.Tag = val; - } - else if (i == 29) - { - if (videoRequest != null) + case 28: + request.Tag = val; + break; + case 29: { - videoRequest.RequireAvc = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + if (videoRequest != null) + { + videoRequest.RequireAvc = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + } + + break; } - } - else if (i == 30) - { - request.SubtitleCodec = val; - } - else if (i == 31) - { - if (videoRequest != null) + case 30: + request.SubtitleCodec = val; + break; + case 31: { - videoRequest.RequireNonAnamorphic = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + if (videoRequest != null) + { + videoRequest.RequireNonAnamorphic = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + } + + break; } - } - else if (i == 32) - { - if (videoRequest != null) + case 32: { - videoRequest.DeInterlace = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + if (videoRequest != null) + { + videoRequest.DeInterlace = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + } + + break; } - } - else if (i == 33) - { - request.TranscodeReasons = val; + case 33: + request.TranscodeReasons = val; + break; } } } @@ -624,14 +639,9 @@ namespace MediaBrowser.Api.Playback throw new ArgumentException("Invalid timeseek header"); } int index = value.IndexOf('-'); - if (index == -1) - { - value = value.Substring(Npt.Length); - } - else - { - value = value.Substring(Npt.Length, index - Npt.Length); - } + value = index == -1 + ? value.Substring(Npt.Length) + : value.Substring(Npt.Length, index - Npt.Length); if (value.IndexOf(':') == -1) { diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index d30175e762..2375e05d02 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -662,17 +662,9 @@ namespace MediaBrowser.Api.Playback }; }).ThenBy(i => { - if (maxBitrate.HasValue) + if (maxBitrate.HasValue && i.Bitrate.HasValue) { - if (i.Bitrate.HasValue) - { - if (i.Bitrate.Value <= maxBitrate.Value) - { - return 0; - } - - return 2; - } + return i.Bitrate.Value <= maxBitrate.Value ? 0 : 2; } return 1; diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.cs index c5b78828cb..d4e2f44df6 100644 --- a/MediaBrowser.Api/SearchService.cs +++ b/MediaBrowser.Api/SearchService.cs @@ -234,46 +234,44 @@ namespace MediaBrowser.Api SetThumbImageInfo(result, item); SetBackdropImageInfo(result, item); - if (item is LiveTvProgram program) + switch (item) { - result.StartDate = program.StartDate; - } - - if (item is IHasSeries hasSeries) - { - result.Series = hasSeries.SeriesName; - } - - if (item is Series series) - { - if (series.Status.HasValue) + case IHasSeries hasSeries: + result.Series = hasSeries.SeriesName; + break; + case LiveTvProgram program: + result.StartDate = program.StartDate; + break; + case Series series: { - result.Status = series.Status.Value.ToString(); - } - } - - if (item is MusicAlbum album) - { - result.Artists = album.Artists; - result.AlbumArtist = album.AlbumArtist; - } - - if (item is Audio song) - { - result.AlbumArtist = song.AlbumArtists.FirstOrDefault(); - result.Artists = song.Artists; + if (series.Status.HasValue) + { + result.Status = series.Status.Value.ToString(); + } - album = song.AlbumEntity; - - if (album != null) - { - result.Album = album.Name; - result.AlbumId = album.Id; - } - else - { - result.Album = song.Album; + break; } + case MusicAlbum album: + result.Artists = album.Artists; + result.AlbumArtist = album.AlbumArtist; + break; + case Audio song: + result.AlbumArtist = song.AlbumArtists.FirstOrDefault(); + result.Artists = song.Artists; + + MusicAlbum musicAlbum = song.AlbumEntity; + + if (musicAlbum != null) + { + result.Album = musicAlbum.Name; + result.AlbumId = musicAlbum.Id; + } + else + { + result.Album = song.Album; + } + + break; } if (!item.ChannelId.Equals(Guid.Empty)) @@ -289,12 +287,9 @@ namespace MediaBrowser.Api { var itemWithImage = item.HasImage(ImageType.Thumb) ? item : null; - if (itemWithImage == null) + if (itemWithImage == null && item is Episode) { - if (item is Episode) - { - itemWithImage = GetParentWithImage(item, ImageType.Thumb); - } + itemWithImage = GetParentWithImage(item, ImageType.Thumb); } if (itemWithImage == null) diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index 3a3eeb8b8f..cfede6f693 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -168,12 +168,8 @@ namespace MediaBrowser.Api.System .First(i => string.Equals(i.Name, request.Name, StringComparison.OrdinalIgnoreCase)); // For older files, assume fully static - if (file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1)) - { - return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShare.Read); - } - - return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShare.ReadWrite); + return ResultFactory.GetStaticFileResult(Request, file.FullName, + file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1) ? FileShare.Read : FileShare.ReadWrite); } /// diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index adb0a440f6..3d08d5437c 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -126,12 +126,7 @@ namespace MediaBrowser.Api.UserLibrary protected override QueryResult<(BaseItem, ItemCounts)> GetItems(GetItemsByName request, InternalItemsQuery query) { - if (request is GetAlbumArtists) - { - return LibraryManager.GetAlbumArtists(query); - } - - return LibraryManager.GetArtists(query); + return request is GetAlbumArtists ? LibraryManager.GetAlbumArtists(query) : LibraryManager.GetArtists(query); } /// diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index a26f59573c..03cf7cabe5 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -396,12 +396,10 @@ namespace MediaBrowser.Api.UserLibrary public VideoType[] GetVideoTypes() { - if (string.IsNullOrEmpty(VideoTypes)) - { - return Array.Empty(); - } - - return VideoTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray(); + return string.IsNullOrEmpty(VideoTypes) + ? Array.Empty() + : VideoTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) + .Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray(); } /// @@ -412,12 +410,10 @@ namespace MediaBrowser.Api.UserLibrary { var val = Filters; - if (string.IsNullOrEmpty(val)) - { - return new ItemFilter[] { }; - } - - return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)).ToArray(); + return string.IsNullOrEmpty(val) + ? new ItemFilter[] { } + : val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries). + Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)).ToArray(); } /// @@ -428,12 +424,9 @@ namespace MediaBrowser.Api.UserLibrary { var val = ImageTypes; - if (string.IsNullOrEmpty(val)) - { - return new ImageType[] { }; - } - - return val.Split(',').Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToArray(); + return string.IsNullOrEmpty(val) + ? new ImageType[] { } + : val.Split(',').Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToArray(); } ///