From add0a2088de154137cf547f84c85f59a78e442d8 Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Sun, 5 Apr 2020 14:44:14 -0400 Subject: Simplified Conditionals and returns --- MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 29 +++++++++--------------- 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs') diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index a26f59573..03cf7cabe 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(); } /// -- cgit v1.2.3 From 81b4a4c54c63822692cd3936fc3c7d8d6e45397c Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Sun, 5 Apr 2020 17:58:39 -0400 Subject: Implement various suggestions --- MediaBrowser.Api/ApiEntryPoint.cs | 6 +-- MediaBrowser.Api/ChannelService.cs | 12 +++--- MediaBrowser.Api/ItemLookupService.cs | 3 +- MediaBrowser.Api/Library/LibraryService.cs | 1 + MediaBrowser.Api/Playback/BaseStreamingService.cs | 47 +++-------------------- MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 3 +- MediaBrowser.Api/SearchService.cs | 2 - MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 12 +++--- MediaBrowser.Api/VideosService.cs | 26 ++++++++----- 9 files changed, 43 insertions(+), 69 deletions(-) (limited to 'MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs') diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 61ad976ec..6691080bc 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -484,9 +484,9 @@ namespace MediaBrowser.Api /// Task. internal Task KillTranscodingJobs(string deviceId, string playSessionId, Func deleteFiles) { - return KillTranscodingJobs(j => !string.IsNullOrWhiteSpace(playSessionId) - ? string.Equals(playSessionId, j.PlaySessionId, StringComparison.OrdinalIgnoreCase) - : string.Equals(deviceId, j.DeviceId, StringComparison.OrdinalIgnoreCase), deleteFiles); + return KillTranscodingJobs(j => string.IsNullOrWhiteSpace(playSessionId) + ? string.Equals(deviceId, j.DeviceId, StringComparison.OrdinalIgnoreCase) + : string.Equals(playSessionId, j.PlaySessionId, StringComparison.OrdinalIgnoreCase), deleteFiles); } /// diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index e43e34133..fd9b8c396 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -117,8 +117,8 @@ namespace MediaBrowser.Api var val = Filters; return string.IsNullOrEmpty(val) - ? new ItemFilter[] { } - : val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)); + ? Array.Empty() + : val.Split(',').Select(v => Enum.Parse(v, true)); } /// @@ -170,11 +170,9 @@ namespace MediaBrowser.Api /// IEnumerable{ItemFilter}. public IEnumerable GetFilters() { - var val = Filters; - - return string.IsNullOrEmpty(val) - ? new ItemFilter[] { } - : val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)); + return string.IsNullOrEmpty(Filters) + ? Array.Empty() + : Filters.Split(',').Select(v => Enum.Parse(v, true)); } } diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index 5a7b1f37a..0bbe7e1cf 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -306,7 +306,8 @@ namespace MediaBrowser.Api Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath)); using (var stream = result.Content) { - using var fileStream = new FileStream(fullCachePath, + using var fileStream = new FileStream( + fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 9251343e8..6f6c1864e 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -393,6 +393,7 @@ namespace MediaBrowser.Api.Library { return true; } + if (string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase) || string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase) || string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase)) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 7c9e65fe7..eb44cb426 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -137,7 +137,9 @@ namespace MediaBrowser.Api.Playback var ext = outputFileExtension.ToLowerInvariant(); var folder = ServerConfigurationManager.GetTranscodePath(); - return EnableOutputInSubFolder ? Path.Combine(folder, filename, filename + ext) : Path.Combine(folder, filename + ext); + return EnableOutputInSubFolder + ? Path.Combine(folder, filename, filename + ext) + : Path.Combine(folder, filename + ext); } protected virtual string GetDefaultEncoderPreset() @@ -393,44 +395,36 @@ namespace MediaBrowser.Api.Playback request.Static = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); break; case 4: - { if (videoRequest != null) { videoRequest.VideoCodec = val; } break; - } case 5: request.AudioCodec = val; break; case 6: - { if (videoRequest != null) { videoRequest.AudioStreamIndex = int.Parse(val, CultureInfo.InvariantCulture); } break; - } case 7: - { if (videoRequest != null) { videoRequest.SubtitleStreamIndex = int.Parse(val, CultureInfo.InvariantCulture); } break; - } case 8: - { if (videoRequest != null) { videoRequest.VideoBitRate = int.Parse(val, CultureInfo.InvariantCulture); } break; - } case 9: request.AudioBitRate = int.Parse(val, CultureInfo.InvariantCulture); break; @@ -438,71 +432,57 @@ namespace MediaBrowser.Api.Playback request.MaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture); break; case 11: - { if (videoRequest != null) { videoRequest.MaxFramerate = float.Parse(val, CultureInfo.InvariantCulture); } break; - } case 12: - { if (videoRequest != null) { videoRequest.MaxWidth = int.Parse(val, CultureInfo.InvariantCulture); } break; - } case 13: - { if (videoRequest != null) { videoRequest.MaxHeight = int.Parse(val, CultureInfo.InvariantCulture); } break; - } case 14: request.StartTimeTicks = long.Parse(val, CultureInfo.InvariantCulture); break; case 15: - { if (videoRequest != null) { videoRequest.Level = val; } break; - } case 16: - { if (videoRequest != null) { videoRequest.MaxRefFrames = int.Parse(val, CultureInfo.InvariantCulture); } break; - } case 17: - { if (videoRequest != null) { videoRequest.MaxVideoBitDepth = int.Parse(val, CultureInfo.InvariantCulture); } break; - } case 18: - { if (videoRequest != null) { videoRequest.Profile = val; } break; - } case 19: // cabac no longer used break; @@ -519,16 +499,13 @@ namespace MediaBrowser.Api.Playback // Duplicating ItemId because of MediaMonkey break; case 24: - { if (videoRequest != null) { videoRequest.CopyTimestamps = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); } break; - } case 25: - { if (!string.IsNullOrWhiteSpace(val) && videoRequest != null) { if (Enum.TryParse(val, out SubtitleDeliveryMethod method)) @@ -538,52 +515,43 @@ namespace MediaBrowser.Api.Playback } break; - } case 26: request.TranscodingMaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture); break; case 27: - { if (videoRequest != null) { videoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); } break; - } case 28: request.Tag = val; break; case 29: - { if (videoRequest != null) { videoRequest.RequireAvc = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); } break; - } case 30: request.SubtitleCodec = val; break; case 31: - { if (videoRequest != null) { videoRequest.RequireNonAnamorphic = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); } break; - } case 32: - { if (videoRequest != null) { videoRequest.DeInterlace = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); } break; - } case 33: request.TranscodeReasons = val; break; @@ -860,14 +828,11 @@ namespace MediaBrowser.Api.Playback { state.DeviceProfile = DlnaManager.GetProfile(state.Request.DeviceProfileId); } - else + else if (!string.IsNullOrWhiteSpace(state.Request.DeviceId)) { - if (!string.IsNullOrWhiteSpace(state.Request.DeviceId)) - { - var caps = DeviceManager.GetCapabilities(state.Request.DeviceId); + var caps = DeviceManager.GetCapabilities(state.Request.DeviceId); - state.DeviceProfile = caps != null ? caps.DeviceProfile : DlnaManager.GetProfile(headers); - } + state.DeviceProfile = caps == null ? DlnaManager.GetProfile(headers) : caps.DeviceProfile; } var profile = state.DeviceProfile; diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 8d5d2279e..52962366c 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -240,7 +240,8 @@ namespace MediaBrowser.Api.Playback.Hls protected Stream GetPlaylistFileStream(string path) { - return new FileStream(path, + return new FileStream( + path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.cs index d4e2f44df..15148d1c7 100644 --- a/MediaBrowser.Api/SearchService.cs +++ b/MediaBrowser.Api/SearchService.cs @@ -243,14 +243,12 @@ namespace MediaBrowser.Api result.StartDate = program.StartDate; break; case Series series: - { if (series.Status.HasValue) { result.Status = series.Status.Value.ToString(); } break; - } case MusicAlbum album: result.Artists = album.Artists; result.AlbumArtist = album.AlbumArtist; diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index 03cf7cabe..eb2f5996e 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -399,7 +399,7 @@ namespace MediaBrowser.Api.UserLibrary return string.IsNullOrEmpty(VideoTypes) ? Array.Empty() : VideoTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) - .Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray(); + .Select(v => Enum.Parse(v, true)).ToArray(); } /// @@ -411,9 +411,9 @@ namespace MediaBrowser.Api.UserLibrary var val = Filters; return string.IsNullOrEmpty(val) - ? new ItemFilter[] { } + ? Array.Empty() : val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries). - Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)).ToArray(); + Select(v => Enum.Parse(v, true)).ToArray(); } /// @@ -426,7 +426,7 @@ namespace MediaBrowser.Api.UserLibrary return string.IsNullOrEmpty(val) ? new ImageType[] { } - : val.Split(',').Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToArray(); + : val.Split(',').Select(v => Enum.Parse(v, true)).ToArray(); } /// @@ -462,7 +462,9 @@ namespace MediaBrowser.Api.UserLibrary var sortOrderIndex = sortOrders.Length > i ? i : 0; var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null; - var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase) ? MediaBrowser.Model.Entities.SortOrder.Descending : MediaBrowser.Model.Entities.SortOrder.Ascending; + var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase) + ? MediaBrowser.Model.Entities.SortOrder.Descending + : MediaBrowser.Model.Entities.SortOrder.Ascending; result[i] = new ValueTuple(vals[i], sortOrder); } diff --git a/MediaBrowser.Api/VideosService.cs b/MediaBrowser.Api/VideosService.cs index 76e9f421d..b11fd48d3 100644 --- a/MediaBrowser.Api/VideosService.cs +++ b/MediaBrowser.Api/VideosService.cs @@ -138,15 +138,23 @@ namespace MediaBrowser.Api var videosWithVersions = items.Where(i => i.MediaSourceCount > 1) .ToList(); - var primaryVersion = videosWithVersions.FirstOrDefault() ?? items.OrderBy(i - => (i.Video3DFormat.HasValue || i.VideoType != Model.Entities.VideoType.VideoFile) ? 1 : 0) - .ThenByDescending(i => - { - var stream = i.GetDefaultVideoStream(); - - return stream?.Width ?? 0; - - }).First(); + var primaryVersion = videosWithVersions.FirstOrDefault(); + if (primaryVersion == null) + { + primaryVersion = items.OrderBy(i => + { + if (i.Video3DFormat.HasValue || i.VideoType != Model.Entities.VideoType.VideoFile) + { + return 1; + } + + return 0; + }) + .ThenByDescending(i => + { + return i.GetDefaultVideoStream()?.Width ?? 0; + }).First(); + } var list = primaryVersion.LinkedAlternateVersions.ToList(); -- cgit v1.2.3 From c9da49ebaa28df3dce6e68078381508cebe4c890 Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Sun, 5 Apr 2020 23:12:25 -0400 Subject: Implemented more suggestions --- MediaBrowser.Api/BaseApiService.cs | 10 ++- MediaBrowser.Api/Library/LibraryService.cs | 84 ++++++++++++------------ MediaBrowser.Api/SearchService.cs | 2 +- MediaBrowser.Api/System/SystemService.cs | 5 +- MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 2 +- 5 files changed, 55 insertions(+), 48 deletions(-) (limited to 'MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs') 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(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().FirstOrDefault() ?? libraryManager.GetItemList(new InternalItemsQuery + }).OfType().FirstOrDefault(); + + result ??= libraryManager.GetItemList(new InternalItemsQuery { Name = name.Replace(BaseItem.SlugChar, '/'), IncludeItemTypes = new[] { typeof(T).Name }, DtoOptions = dtoOptions - }).OfType().FirstOrDefault()) ?? libraryManager.GetItemList(new InternalItemsQuery + }).OfType().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 themeItems = item.GetThemeSongs(); + IEnumerable 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 themeItems = item.GetThemeVideos(); + IEnumerable 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(item, ImageType.Backdrop); + ?? GetParentWithImage(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); } /// 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() : val.Split(',').Select(v => Enum.Parse(v, true)).ToArray(); } -- cgit v1.2.3 From 555651aae23e788b10760d58840114d8a010da90 Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Mon, 6 Apr 2020 23:17:49 -0400 Subject: Fixed indentation and corrected typo --- MediaBrowser.Api/Library/LibraryService.cs | 10 +++++----- MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs') diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 26be9db83..a54640b2f 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -389,13 +389,13 @@ namespace MediaBrowser.Api.Library if (string.Equals(name, "TheMovieDb", StringComparison.OrdinalIgnoreCase)) { return !(string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase) - || string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase) - || string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase)); + || string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase) + || string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase)); } return string.Equals(name, "TheTVDB", StringComparison.OrdinalIgnoreCase) - || string.Equals(name, "TheAudioDB", StringComparison.OrdinalIgnoreCase) - || string.Equals(name, "MusicBrainz", StringComparison.OrdinalIgnoreCase); + || string.Equals(name, "TheAudioDB", StringComparison.OrdinalIgnoreCase) + || string.Equals(name, "MusicBrainz", StringComparison.OrdinalIgnoreCase); } var metadataOptions = ServerConfigurationManager.Configuration.MetadataOptions @@ -403,7 +403,7 @@ namespace MediaBrowser.Api.Library .ToArray(); return metadataOptions.Length == 0 - || metadataOptions.Any(i => !i.DisabledMetadataFetchers.Contains(name, StringComparer.OrdinalIgnoreCase)); + || metadataOptions.Any(i => !i.DisabledMetadataFetchers.Contains(name, StringComparer.OrdinalIgnoreCase)); } private bool IsImageFetcherEnabledByDefault(string name, string type, bool isNewLibrary) diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index f9f66f135..7561b5c89 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -412,8 +412,8 @@ namespace MediaBrowser.Api.UserLibrary return string.IsNullOrEmpty(val) ? Array.Empty() - : val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries). - Select(v => Enum.Parse(v, true)).ToArray(); + : val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) + .Select(v => Enum.Parse(v, true)).ToArray(); } /// -- cgit v1.2.3