diff options
Diffstat (limited to 'MediaBrowser.Controller')
40 files changed, 240 insertions, 254 deletions
diff --git a/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs b/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs index 61539cae5..ed7c2c2c1 100644 --- a/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs +++ b/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs @@ -49,14 +49,14 @@ namespace MediaBrowser.Controller.BaseItemManager return !baseItem.EnableMediaSourceDisplay; } - if (libraryTypeOptions != null) + if (libraryTypeOptions is not null) { return libraryTypeOptions.MetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); } var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase)); - return itemConfig == null || !itemConfig.DisabledMetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); + return itemConfig is null || !itemConfig.DisabledMetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); } /// <inheritdoc /> @@ -74,14 +74,14 @@ namespace MediaBrowser.Controller.BaseItemManager return !baseItem.EnableMediaSourceDisplay; } - if (libraryTypeOptions != null) + if (libraryTypeOptions is not null) { return libraryTypeOptions.ImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); } var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase)); - return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); + return itemConfig is null || !itemConfig.DisabledImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase); } /// <summary> diff --git a/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs b/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs index b036425ab..62b70ce53 100644 --- a/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs +++ b/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Drawing { var imageInfo = item.GetImageInfo(imageType, imageIndex); - if (imageInfo == null) + if (imageInfo is null) { return null; } diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index e671e5c71..08c622cde 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -67,14 +67,14 @@ namespace MediaBrowser.Controller.Entities { lock (_childIdsLock) { - if (_childrenIds == null || _childrenIds.Length == 0) + if (_childrenIds is null || _childrenIds.Length == 0) { var list = base.LoadChildren(); _childrenIds = list.Select(i => i.Id).ToArray(); return list; } - return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList(); + return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i is not null).ToList(); } } diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 29f7bf92b..c7216a320 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -81,8 +81,8 @@ namespace MediaBrowser.Controller.Entities.Audio /// <returns>System.String.</returns> protected override string CreateSortName() { - return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) - + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + Name; + return (ParentIndexNumber is not null ? ParentIndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + + (IndexNumber is not null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + Name; } public override List<string> GetUserDataKeys() diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 6555de855..2dbd513a1 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Entities.Audio var artist = GetMusicArtist(new DtoOptions(false)); - if (artist != null) + if (artist is not null) { id.ArtistProviderIds = artist.ProviderIds; } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 7f5f9f74b..49dd151f3 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -494,7 +494,7 @@ namespace MediaBrowser.Controller.Entities { get { - if (_sortName == null) + if (_sortName is null) { if (!string.IsNullOrEmpty(ForcedSortName)) { @@ -658,7 +658,7 @@ namespace MediaBrowser.Controller.Entities } var parent = DisplayParent; - if (parent != null) + if (parent is not null) { return parent.OfficialRatingForComparison; } @@ -679,7 +679,7 @@ namespace MediaBrowser.Controller.Entities } var parent = DisplayParent; - if (parent != null) + if (parent is not null) { return parent.CustomRatingForComparison; } @@ -880,7 +880,7 @@ namespace MediaBrowser.Controller.Entities /// <returns>System.String.</returns> protected virtual string CreateSortName() { - if (Name == null) + if (Name is null) { return null; // some items may not have name filled in properly } @@ -976,7 +976,7 @@ namespace MediaBrowser.Controller.Entities { var parent = GetParent(); - while (parent != null) + while (parent is not null) { yield return parent; @@ -1073,7 +1073,7 @@ namespace MediaBrowser.Controller.Entities { var stream = i.VideoStream; - return stream == null || stream.Width == null ? 0 : stream.Width.Value; + return stream is null || stream.Width is null ? 0 : stream.Width.Value; }) .ToList(); } @@ -1114,7 +1114,7 @@ namespace MediaBrowser.Controller.Entities } var video = item as Video; - if (video != null) + if (video is not null) { info.IsoType = video.IsoType; info.VideoType = video.VideoType; @@ -1153,7 +1153,7 @@ namespace MediaBrowser.Controller.Entities info.SupportsDirectStream = MediaSourceManager.SupportsDirectStream(info.Path, info.Protocol); } - if (video != null && video.VideoType != VideoType.VideoFile) + if (video is not null && video.VideoType != VideoType.VideoFile) { info.SupportsDirectStream = false; } @@ -1330,7 +1330,7 @@ namespace MediaBrowser.Controller.Entities public void SetParent(Folder parent) { - ParentId = parent == null ? Guid.Empty : parent.Id; + ParentId = parent is null ? Guid.Empty : parent.Id; } /// <summary> @@ -1534,7 +1534,7 @@ namespace MediaBrowser.Controller.Entities var maxAllowedRating = user.MaxParentalAgeRating; - if (maxAllowedRating == null) + if (maxAllowedRating is null) { return true; } @@ -1692,7 +1692,7 @@ namespace MediaBrowser.Controller.Entities var itemById = LibraryManager.GetItemById(info.ItemId.Value); - if (itemById != null) + if (itemById is not null) { return itemById; } @@ -1701,7 +1701,7 @@ namespace MediaBrowser.Controller.Entities var item = FindLinkedChild(info); // If still null, log - if (item == null) + if (item is null) { // Don't keep searching over and over info.ItemId = Guid.Empty; @@ -1725,7 +1725,7 @@ namespace MediaBrowser.Controller.Entities var itemByPath = LibraryManager.FindByPath(path, null); - if (itemByPath == null) + if (itemByPath is null) { Logger.LogWarning("Unable to find linked item at path {0}", info.Path); } @@ -1737,7 +1737,7 @@ namespace MediaBrowser.Controller.Entities { var item = LibraryManager.GetItemById(info.LibraryItemId); - if (item == null) + if (item is null) { Logger.LogWarning("Unable to find linked item at path {0}", info.Path); } @@ -1755,10 +1755,7 @@ namespace MediaBrowser.Controller.Entities /// <exception cref="ArgumentNullException">Throws if name is null.</exception> public void AddStudio(string name) { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException(nameof(name)); - } + ArgumentException.ThrowIfNullOrEmpty(name); var current = Studios; @@ -1791,10 +1788,7 @@ namespace MediaBrowser.Controller.Entities /// <exception cref="ArgumentNullException">Throwns if name is null.</exception> public void AddGenre(string name) { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentNullException(nameof(name)); - } + ArgumentException.ThrowIfNullOrEmpty(name); var genres = Genres; if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase)) @@ -1892,7 +1886,7 @@ namespace MediaBrowser.Controller.Entities var existingImage = GetImageInfo(image.Type, index); - if (existingImage == null) + if (existingImage is null) { AddImage(image); } @@ -1915,7 +1909,7 @@ namespace MediaBrowser.Controller.Entities var image = GetImageInfo(type, index); - if (image == null) + if (image is null) { AddImage(GetImageInfo(file, type)); } @@ -1942,7 +1936,7 @@ namespace MediaBrowser.Controller.Entities { var info = GetImageInfo(type, index); - if (info == null) + if (info is null) { // Nothing to do return; @@ -2035,7 +2029,7 @@ namespace MediaBrowser.Controller.Entities { var chapter = ItemRepository.GetChapter(this, imageIndex); - if (chapter == null) + if (chapter is null) { return null; } @@ -2060,7 +2054,7 @@ namespace MediaBrowser.Controller.Entities { var artist = FindParent<MusicArtist>(); - if (artist != null) + if (artist is not null) { return artist.GetImages(imageType).ElementAtOrDefault(imageIndex); } @@ -2147,7 +2141,7 @@ namespace MediaBrowser.Controller.Entities foreach (var newImage in images) { - if (newImage == null) + if (newImage is null) { throw new ArgumentException("null image found in list"); } @@ -2155,7 +2149,7 @@ namespace MediaBrowser.Controller.Entities var existing = existingImages .Find(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase)); - if (existing == null) + if (existing is null) { newImageList.Add(newImage); } @@ -2241,7 +2235,7 @@ namespace MediaBrowser.Controller.Entities var info1 = GetImageInfo(type, index1); var info2 = GetImageInfo(type, index2); - if (info1 == null || info2 == null) + if (info1 is null || info2 is null) { // Nothing to do return Task.CompletedTask; @@ -2274,14 +2268,14 @@ namespace MediaBrowser.Controller.Entities { var userdata = UserDataManager.GetUserData(user, this); - return userdata != null && userdata.Played; + return userdata is not null && userdata.Played; } public bool IsFavoriteOrLiked(User user) { var userdata = UserDataManager.GetUserData(user, this); - return userdata != null && (userdata.IsFavorite || (userdata.Likes ?? false)); + return userdata is not null && (userdata.IsFavorite || (userdata.Likes ?? false)); } public virtual bool IsUnplayed(User user) @@ -2290,7 +2284,7 @@ namespace MediaBrowser.Controller.Entities var userdata = UserDataManager.GetUserData(user, this); - return userdata == null || !userdata.Played; + return userdata is null || !userdata.Played; } ItemLookupInfo IHasLookupInfo<ItemLookupInfo>.GetLookupInfo() @@ -2445,18 +2439,23 @@ namespace MediaBrowser.Controller.Entities // Try to retrieve it from the db. If we don't find it, use the resolved version var video = LibraryManager.GetItemById(id) as Video; - if (video == null) + if (video is null) { video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video; newOptions.ForceSave = true; } - if (video == null) + if (video is null) { return Task.FromResult(true); } + if (video.OwnerId.Equals(default)) + { + video.OwnerId = this.Id; + } + return RefreshMetadataForOwnedItem(video, copyTitleMetadata, newOptions, cancellationToken); } @@ -2565,7 +2564,7 @@ namespace MediaBrowser.Controller.Entities { return ExtraIds .Select(LibraryManager.GetItemById) - .Where(i => i != null) + .Where(i => i is not null) .OrderBy(i => i.SortName); } @@ -2578,7 +2577,7 @@ namespace MediaBrowser.Controller.Entities { return ExtraIds .Select(LibraryManager.GetItemById) - .Where(i => i != null) + .Where(i => i is not null) .Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value)) .OrderBy(i => i.SortName); } diff --git a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs index 948eb4375..615d236c7 100644 --- a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs +++ b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs @@ -89,13 +89,13 @@ namespace MediaBrowser.Controller.Entities } var v = sourceProp.GetValue(source); - if (v == null) + if (v is null) { continue; } var p = destProps.Find(x => x.Name == sourceProp.Name); - if (p != null) + if (p is not null) { p.SetValue(dest, v); } diff --git a/MediaBrowser.Controller/Entities/Extensions.cs b/MediaBrowser.Controller/Entities/Extensions.cs index 1acb92fdc..3005bee0a 100644 --- a/MediaBrowser.Controller/Entities/Extensions.cs +++ b/MediaBrowser.Controller/Entities/Extensions.cs @@ -17,16 +17,11 @@ namespace MediaBrowser.Controller.Entities /// <param name="url">Trailer URL.</param> public static void AddTrailerUrl(this BaseItem item, string url) { - ArgumentNullException.ThrowIfNull(url); - - if (url.Length == 0) - { - throw new ArgumentException("String can't be empty", nameof(url)); - } + ArgumentException.ThrowIfNullOrEmpty(url); var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase)); - if (current == null) + if (current is null) { var mediaUrl = new MediaUrl { diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 808f91810..e586205c3 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -483,7 +483,7 @@ namespace MediaBrowser.Controller.Entities } }); - if (container != null) + if (container is not null) { await RefreshAllMetadataForContainer(container, refreshOptions, innerProgress, cancellationToken).ConfigureAwait(false); } @@ -515,7 +515,7 @@ namespace MediaBrowser.Controller.Entities async () => { var series = container as Series; - if (series != null) + if (series is not null) { await series.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); } @@ -529,7 +529,7 @@ namespace MediaBrowser.Controller.Entities { var container = child as IMetadataContainer; - if (container != null) + if (container is not null) { await RefreshAllMetadataForContainer(container, refreshOptions, progress, cancellationToken).ConfigureAwait(false); } @@ -703,7 +703,7 @@ namespace MediaBrowser.Controller.Entities IEnumerable<BaseItem> items; Func<BaseItem, bool> filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager); - if (query.User == null) + if (query.User is null) { items = GetRecursiveChildren(filter); } @@ -741,7 +741,7 @@ namespace MediaBrowser.Controller.Entities IEnumerable<BaseItem> itemsList = LibraryManager.GetItemList(query); var user = query.User; - if (user != null) + if (user is not null) { // needed for boxsets itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User)); @@ -961,7 +961,7 @@ namespace MediaBrowser.Controller.Entities IEnumerable<BaseItem> items; - if (query.User == null) + if (query.User is null) { items = Children.Where(filter); } @@ -984,7 +984,7 @@ namespace MediaBrowser.Controller.Entities var user = query.User; // Check recursive - don't substitute in plain folder views - if (user != null) + if (user is not null) { items = CollapseBoxSetItemsIfNeeded(items, query, this, user, ConfigurationManager, CollectionManager); } @@ -1069,7 +1069,7 @@ namespace MediaBrowser.Controller.Entities if (!param.HasValue) { - if (user != null && !configurationManager.Configuration.EnableGroupingIntoCollections) + if (user is not null && !configurationManager.Configuration.EnableGroupingIntoCollections) { return false; } @@ -1311,7 +1311,7 @@ namespace MediaBrowser.Controller.Entities } // If there are not sub-folders, proceed as normal. - if (children == null) + if (children is null) { children = GetEligibleChildrenForRecursiveChildren(user); } @@ -1320,7 +1320,7 @@ namespace MediaBrowser.Controller.Entities { bool? isVisibleToUser = null; - if (query == null || UserViewBuilder.FilterItem(child, query)) + if (query is null || UserViewBuilder.FilterItem(child, query)) { isVisibleToUser = child.IsVisible(user); @@ -1345,7 +1345,7 @@ namespace MediaBrowser.Controller.Entities { foreach (var child in GetLinkedChildren(user)) { - if (query == null || UserViewBuilder.FilterItem(child, query)) + if (query is null || UserViewBuilder.FilterItem(child, query)) { if (child.IsVisible(user)) { @@ -1402,7 +1402,7 @@ namespace MediaBrowser.Controller.Entities { foreach (var child in Children) { - if (filter == null || filter(child)) + if (filter is null || filter(child)) { result[child.Id] = child; } @@ -1420,7 +1420,7 @@ namespace MediaBrowser.Controller.Entities { foreach (var child in GetLinkedChildren()) { - if (filter == null || filter(child)) + if (filter is null || filter(child)) { result[child.Id] = child; } @@ -1441,7 +1441,7 @@ namespace MediaBrowser.Controller.Entities { var child = GetLinkedChild(i); - if (child != null) + if (child is not null) { list.Add(child); } @@ -1467,7 +1467,7 @@ namespace MediaBrowser.Controller.Entities var child = GetLinkedChild(i); - if (child != null && child.Id.Equals(itemId)) + if (child is not null && child.Id.Equals(itemId)) { return true; } @@ -1478,7 +1478,7 @@ namespace MediaBrowser.Controller.Entities public List<BaseItem> GetLinkedChildren(User user) { - if (!FilterLinkedChildrenPerUser || user == null) + if (!FilterLinkedChildrenPerUser || user is null) { return GetLinkedChildren(); } @@ -1504,7 +1504,7 @@ namespace MediaBrowser.Controller.Entities { var child = GetLinkedChild(i); - if (child == null) + if (child is null) { continue; } @@ -1547,7 +1547,7 @@ namespace MediaBrowser.Controller.Entities { return LinkedChildren .Select(i => new Tuple<LinkedChild, BaseItem>(i, GetLinkedChild(i))) - .Where(i => i.Item2 != null); + .Where(i => i.Item2 is not null); } protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, IReadOnlyList<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) @@ -1605,7 +1605,7 @@ namespace MediaBrowser.Controller.Entities return null; } }) - .Where(i => i != null) + .Where(i => i is not null) .ToList(); var currentShortcutLinks = LinkedChildren.Where(i => i.Type == LinkedChildType.Shortcut).ToList(); @@ -1662,7 +1662,7 @@ namespace MediaBrowser.Controller.Entities { // The querying doesn't support virtual unaired var episode = item as Episode; - if (episode != null && episode.IsUnaired) + if (episode is not null && episode.IsUnaired) { continue; } @@ -1719,7 +1719,7 @@ namespace MediaBrowser.Controller.Entities return; } - if (itemDto != null) + if (itemDto is not null) { if (fields.ContainsField(ItemFields.RecursiveItemCount)) { diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 1bf528538..a1e531904 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Controller.Entities public InternalItemsQuery(User? user) : this() { - if (user != null) + if (user is not null) { SetUser(user); } @@ -316,7 +316,7 @@ namespace MediaBrowser.Controller.Entities { set { - if (value == null) + if (value is null) { ParentId = Guid.Empty; ParentType = null; diff --git a/MediaBrowser.Controller/Entities/ItemImageInfo.cs b/MediaBrowser.Controller/Entities/ItemImageInfo.cs index ea8555dbf..0171af27c 100644 --- a/MediaBrowser.Controller/Entities/ItemImageInfo.cs +++ b/MediaBrowser.Controller/Entities/ItemImageInfo.cs @@ -39,6 +39,6 @@ namespace MediaBrowser.Controller.Entities public string BlurHash { get; set; } [JsonIgnore] - public bool IsLocalFile => Path == null || !Path.StartsWith("http", StringComparison.OrdinalIgnoreCase); + public bool IsLocalFile => Path is null || !Path.StartsWith("http", StringComparison.OrdinalIgnoreCase); } } diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 3c12acd90..81f6248fa 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Entities.Movies /// <inheritdoc /> [JsonIgnore] public IReadOnlyList<Guid> SpecialFeatureIds => GetExtras() - .Where(extra => extra.ExtraType != null && extra is Video) + .Where(extra => extra.ExtraType is not null && extra is Video) .Select(extra => extra.Id) .ToArray(); diff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.cs index 8571bfcea..7f8dc069c 100644 --- a/MediaBrowser.Controller/Entities/PeopleHelper.cs +++ b/MediaBrowser.Controller/Entities/PeopleHelper.cs @@ -12,11 +12,7 @@ namespace MediaBrowser.Controller.Entities public static void AddPerson(List<PersonInfo> people, PersonInfo person) { ArgumentNullException.ThrowIfNull(person); - - if (string.IsNullOrEmpty(person.Name)) - { - throw new ArgumentException("The person's name was empty or null.", nameof(person)); - } + ArgumentException.ThrowIfNullOrEmpty(person.Name); // Normalize if (string.Equals(person.Role, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase)) @@ -41,7 +37,7 @@ namespace MediaBrowser.Controller.Entities { var existing = people.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase)); - if (existing != null) + if (existing is not null) { existing.Type = PersonType.GuestStar; MergeExisting(existing, person); @@ -53,7 +49,7 @@ namespace MediaBrowser.Controller.Entities { // If the actor already exists without a role and we have one, fill it in var existing = people.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && (p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase) || p.Type.Equals(PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))); - if (existing == null) + if (existing is null) { // Wasn't there - add it people.Add(person); @@ -76,7 +72,7 @@ namespace MediaBrowser.Controller.Entities string.Equals(p.Type, person.Type, StringComparison.OrdinalIgnoreCase)); // Check for dupes based on the combination of Name and Type - if (existing == null) + if (existing is null) { people.Add(person); } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 15b721fe6..3f30ac565 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -136,7 +136,7 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesSortName() { var series = Series; - return series == null ? SeriesName : series.SortName; + return series is null ? SeriesName : series.SortName; } public override double GetDefaultPrimaryImageAspectRatio() @@ -155,7 +155,7 @@ namespace MediaBrowser.Controller.Entities.TV var list = base.GetUserDataKeys(); var series = Series; - if (series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue) + if (series is not null && ParentIndexNumber.HasValue && IndexNumber.HasValue) { var seriesUserDataKeys = series.GetUserDataKeys(); var take = seriesUserDataKeys.Count; @@ -181,14 +181,14 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesPresentationUniqueKey() { var series = Series; - return series == null ? null : series.PresentationUniqueKey; + return series is null ? null : series.PresentationUniqueKey; } public string FindSeasonName() { var season = Season; - if (season == null) + if (season is null) { if (ParentIndexNumber.HasValue) { @@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesName() { var series = Series; - return series == null ? SeriesName : series.Name; + return series is null ? SeriesName : series.Name; } public Guid FindSeasonId() @@ -212,11 +212,11 @@ namespace MediaBrowser.Controller.Entities.TV var season = FindParent<Season>(); // Episodes directly in series folder - if (season == null) + if (season is null) { var series = Series; - if (series != null && ParentIndexNumber.HasValue) + if (series is not null && ParentIndexNumber.HasValue) { var findNumber = ParentIndexNumber.Value; @@ -226,7 +226,7 @@ namespace MediaBrowser.Controller.Entities.TV } } - return season == null ? Guid.Empty : season.Id; + return season is null ? Guid.Empty : season.Id; } /// <summary> @@ -235,8 +235,8 @@ namespace MediaBrowser.Controller.Entities.TV /// <returns>System.String.</returns> protected override string CreateSortName() { - return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("000 - ", CultureInfo.InvariantCulture) : string.Empty) - + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + Name; + return (ParentIndexNumber is not null ? ParentIndexNumber.Value.ToString("000 - ", CultureInfo.InvariantCulture) : string.Empty) + + (IndexNumber is not null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : string.Empty) + Name; } /// <summary> @@ -262,7 +262,7 @@ namespace MediaBrowser.Controller.Entities.TV public Guid FindSeriesId() { var series = FindParent<Series>(); - return series == null ? Guid.Empty : series.Id; + return series is null ? Guid.Empty : series.Id; } public override IEnumerable<Guid> GetAncestorIds() @@ -302,7 +302,7 @@ namespace MediaBrowser.Controller.Entities.TV var series = Series; - if (series != null) + if (series is not null) { id.SeriesProviderIds = series.ProviderIds; id.SeriesDisplayOrder = series.DisplayOrder; diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 599d35da6..0a040a3c2 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -64,7 +64,7 @@ namespace MediaBrowser.Controller.Entities.TV { var series = Series; - if (series != null) + if (series is not null) { return series.Path; } @@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesSortName() { var series = Series; - return series == null ? SeriesName : series.SortName; + return series is null ? SeriesName : series.SortName; } public override List<string> GetUserDataKeys() @@ -101,7 +101,7 @@ namespace MediaBrowser.Controller.Entities.TV var list = base.GetUserDataKeys(); var series = Series; - if (series != null) + if (series is not null) { var newList = series.GetUserDataKeys(); var suffix = (IndexNumber ?? 0).ToString("000", CultureInfo.InvariantCulture); @@ -129,7 +129,7 @@ namespace MediaBrowser.Controller.Entities.TV if (IndexNumber.HasValue) { var series = Series; - if (series != null) + if (series is not null) { return series.PresentationUniqueKey + "-" + (IndexNumber ?? 0).ToString("000", CultureInfo.InvariantCulture); } @@ -144,12 +144,12 @@ namespace MediaBrowser.Controller.Entities.TV /// <returns>System.String.</returns> protected override string CreateSortName() { - return IndexNumber != null ? IndexNumber.Value.ToString("0000", CultureInfo.InvariantCulture) : Name; + return IndexNumber is not null ? IndexNumber.Value.ToString("0000", CultureInfo.InvariantCulture) : Name; } protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) { - if (query.User == null) + if (query.User is null) { return base.GetItemsInternal(query); } @@ -208,13 +208,13 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesPresentationUniqueKey() { var series = Series; - return series == null ? null : series.PresentationUniqueKey; + return series is null ? null : series.PresentationUniqueKey; } public string FindSeriesName() { var series = Series; - return series == null ? SeriesName : series.Name; + return series is null ? SeriesName : series.Name; } public Guid FindSeriesId() @@ -233,7 +233,7 @@ namespace MediaBrowser.Controller.Entities.TV var series = Series; - if (series != null) + if (series is not null) { id.SeriesProviderIds = series.ProviderIds; } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index d66802a64..02312757c 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -218,7 +218,7 @@ namespace MediaBrowser.Controller.Entities.TV query.IncludeItemTypes = new[] { BaseItemKind.Season }; query.OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) }; - if (user != null && !user.DisplayMissingEpisodes) + if (user is not null && !user.DisplayMissingEpisodes) { query.IsMissing = false; } @@ -266,7 +266,7 @@ namespace MediaBrowser.Controller.Entities.TV DtoOptions = options }; - if (user == null || !user.DisplayMissingEpisodes) + if (user is null || !user.DisplayMissingEpisodes) { query.IsMissing = false; } @@ -369,7 +369,7 @@ namespace MediaBrowser.Controller.Entities.TV OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) }, DtoOptions = options }; - if (user != null) + if (user is not null) { if (!user.DisplayMissingEpisodes) { @@ -384,7 +384,7 @@ namespace MediaBrowser.Controller.Entities.TV public List<BaseItem> GetSeasonEpisodes(Season parentSeason, User user, IEnumerable<BaseItem> allSeriesEpisodes, DtoOptions options) { - if (allSeriesEpisodes == null) + if (allSeriesEpisodes is null) { return GetSeasonEpisodes(parentSeason, user, options); } @@ -426,7 +426,7 @@ namespace MediaBrowser.Controller.Entities.TV } var season = episodeItem.Season; - return season != null && string.Equals(GetUniqueSeriesKey(season), seasonPresentationKey, StringComparison.OrdinalIgnoreCase); + return season is not null && string.Equals(GetUniqueSeriesKey(season), seasonPresentationKey, StringComparison.OrdinalIgnoreCase); }); } @@ -448,7 +448,7 @@ namespace MediaBrowser.Controller.Entities.TV { var episode = i; - if (episode != null) + if (episode is not null) { var currentSeasonNumber = episode.AiredSeasonNumber; diff --git a/MediaBrowser.Controller/Entities/UserItemData.cs b/MediaBrowser.Controller/Entities/UserItemData.cs index 50ba9ef30..ecca440f0 100644 --- a/MediaBrowser.Controller/Entities/UserItemData.cs +++ b/MediaBrowser.Controller/Entities/UserItemData.cs @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Entities { get { - if (Rating != null) + if (Rating is not null) { return Rating >= MinLikeValue; } diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index e547db523..69743b926 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -56,14 +56,14 @@ namespace MediaBrowser.Controller.Entities { lock (_childIdsLock) { - if (_childrenIds == null) + if (_childrenIds is null) { var list = base.LoadChildren(); _childrenIds = list.Select(i => i.Id).ToList(); return list; } - return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList(); + return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i is not null).ToList(); } } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index f467a6038..c276ab463 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Entities { var user = query.User; - // if (query.IncludeItemTypes != null && + // if (query.IncludeItemTypes is not null && // query.IncludeItemTypes.Length == 1 && // string.Equals(query.IncludeItemTypes[0], "Playlist", StringComparison.OrdinalIgnoreCase)) // { @@ -263,7 +263,7 @@ namespace MediaBrowser.Controller.Entities return null; } }) - .Where(i => i != null) + .Where(i => i is not null) .Select(i => GetUserViewWithName(SpecialFolder.MovieGenre, i.SortName, parent)); return GetResult(genres, query); @@ -391,7 +391,7 @@ namespace MediaBrowser.Controller.Entities return null; } }) - .Where(i => i != null) + .Where(i => i is not null) .Select(i => GetUserViewWithName(SpecialFolder.TvGenre, i.SortName, parent)); return GetResult(genres, query); @@ -559,7 +559,7 @@ namespace MediaBrowser.Controller.Entities var val = query.Is3D.Value; var video = item as Video; - if (video == null || val != video.Video3DFormat.HasValue) + if (video is null || val != video.Video3DFormat.HasValue) { return false; } @@ -689,7 +689,7 @@ namespace MediaBrowser.Controller.Entities var video = item as Video; - if (video == null || val != video.HasSubtitles) + if (video is null || val != video.HasSubtitles) { return false; } @@ -776,7 +776,7 @@ namespace MediaBrowser.Controller.Entities if (query.VideoTypes.Length > 0) { var video = item as Video; - if (video == null || !query.VideoTypes.Contains(video.VideoType)) + if (video is null || !query.VideoTypes.Contains(video.VideoType)) { return false; } @@ -791,7 +791,7 @@ namespace MediaBrowser.Controller.Entities if (query.StudioIds.Length > 0 && !query.StudioIds.Any(id => { var studioItem = libraryManager.GetItemById(id); - return studioItem != null && item.Studios.Contains(studioItem.Name, StringComparison.OrdinalIgnoreCase); + return studioItem is not null && item.Studios.Contains(studioItem.Name, StringComparison.OrdinalIgnoreCase); })) { return false; @@ -801,7 +801,7 @@ namespace MediaBrowser.Controller.Entities if (query.GenreIds.Count > 0 && !query.GenreIds.Any(id => { var genreItem = libraryManager.GetItemById(id); - return genreItem != null && item.Genres.Contains(genreItem.Name, StringComparison.OrdinalIgnoreCase); + return genreItem is not null && item.Genres.Contains(genreItem.Name, StringComparison.OrdinalIgnoreCase); })) { return false; @@ -913,7 +913,7 @@ namespace MediaBrowser.Controller.Entities { var episode = item as Episode; - if (episode == null) + if (episode is null) { return false; } @@ -929,7 +929,7 @@ namespace MediaBrowser.Controller.Entities private IEnumerable<BaseItem> GetMediaFolders(User user) { - if (user == null) + if (user is null) { return _libraryManager.RootFolder .Children @@ -945,14 +945,14 @@ namespace MediaBrowser.Controller.Entities private BaseItem[] GetMediaFolders(User user, IEnumerable<string> viewTypes) { - if (user == null) + if (user is null) { return GetMediaFolders(null) .Where(i => { var folder = i as ICollectionFolder; - return folder != null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase); + return folder is not null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase); }).ToArray(); } @@ -961,13 +961,13 @@ namespace MediaBrowser.Controller.Entities { var folder = i as ICollectionFolder; - return folder != null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase); + return folder is not null && viewTypes.Contains(folder.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase); }).ToArray(); } private BaseItem[] GetMediaFolders(Folder parent, User user, IEnumerable<string> viewTypes) { - if (parent == null || parent is UserView) + if (parent is null || parent is UserView) { return GetMediaFolders(user, viewTypes); } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 5de2e0f50..5b7abea10 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -373,7 +373,7 @@ namespace MediaBrowser.Controller.Entities { return LinkedAlternateVersions .Select(GetLinkedChild) - .Where(i => i != null) + .Where(i => i is not null) .OfType<Video>() .OrderBy(i => i.SortName); } @@ -386,7 +386,7 @@ namespace MediaBrowser.Controller.Entities { return GetAdditionalPartIds() .Select(i => LibraryManager.GetItemById(i)) - .Where(i => i != null) + .Where(i => i is not null) .OfType<Video>() .OrderBy(i => i.SortName); } @@ -469,7 +469,7 @@ namespace MediaBrowser.Controller.Entities var localAlternates = GetLocalAlternateVersionIds() .Select(i => LibraryManager.GetItemById(i)) - .Where(i => i != null); + .Where(i => i is not null); foreach (var item in localAlternates) { @@ -542,7 +542,7 @@ namespace MediaBrowser.Controller.Entities return i.Item1 is Video video ? video.GetLocalAlternateVersionIds() : Enumerable.Empty<Guid>(); }) .Select(LibraryManager.GetItemById) - .Where(i => i != null) + .Where(i => i is not null) .ToList(); list.AddRange(localAlternates.Select(i => (i, MediaSourceType.Default))); diff --git a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs index 5a7110261..3b5e8ece7 100644 --- a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs +++ b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs @@ -73,7 +73,7 @@ namespace MediaBrowser.Controller.Extensions /// </summary> /// <param name="configuration">The configuration to read the setting from.</param> /// <returns>The FFmpeg probe size option.</returns> - public static string GetFFmpegProbeSize(this IConfiguration configuration) + public static string? GetFFmpegProbeSize(this IConfiguration configuration) => configuration[FfmpegProbeSizeKey]; /// <summary> @@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Extensions /// </summary> /// <param name="configuration">The configuration to read the setting from.</param> /// <returns>The FFmpeg analyze duration option.</returns> - public static string GetFFmpegAnalyzeDuration(this IConfiguration configuration) + public static string? GetFFmpegAnalyzeDuration(this IConfiguration configuration) => configuration[FfmpegAnalyzeDurationKey]; /// <summary> @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Extensions /// </summary> /// <param name="configuration">The configuration to read the setting from.</param> /// <returns>The unix socket path.</returns> - public static string GetUnixSocketPath(this IConfiguration configuration) + public static string? GetUnixSocketPath(this IConfiguration configuration) => configuration[UnixSocketPathKey]; /// <summary> @@ -113,7 +113,7 @@ namespace MediaBrowser.Controller.Extensions /// </summary> /// <param name="configuration">The configuration to read the setting from.</param> /// <returns>The unix socket permissions.</returns> - public static string GetUnixSocketPermissions(this IConfiguration configuration) + public static string? GetUnixSocketPermissions(this IConfiguration configuration) => configuration[UnixSocketPermissionsKey]; } } diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 71feae536..9f7a93ae2 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -35,10 +35,7 @@ namespace MediaBrowser.Controller.IO int flattenFolderDepth = 0, bool resolveShortcuts = true) { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentNullException(nameof(path)); - } + ArgumentException.ThrowIfNullOrEmpty(path); ArgumentNullException.ThrowIfNull(args); diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 5905c25a5..f34e3d68d 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -429,10 +429,16 @@ namespace MediaBrowser.Controller.Library /// Gets the collection folders. /// </summary> /// <param name="item">The item.</param> - /// <returns>IEnumerable<Folder>.</returns> + /// <returns>The folders that contain the item.</returns> List<Folder> GetCollectionFolders(BaseItem item); - List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren); + /// <summary> + /// Gets the collection folders. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="allUserRootChildren">The root folders to consider.</param> + /// <returns>The folders that contain the item.</returns> + List<Folder> GetCollectionFolders(BaseItem item, IEnumerable<Folder> allUserRootChildren); LibraryOptions GetLibraryOptions(BaseItem item); diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 91d162b41..01986d303 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.Library public LibraryOptions LibraryOptions { - get => _libraryOptions ??= Parent == null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent); + get => _libraryOptions ??= Parent is null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent); set => _libraryOptions = value; } @@ -119,7 +119,7 @@ namespace MediaBrowser.Controller.Library get { var paths = string.IsNullOrEmpty(Path) ? Array.Empty<string>() : new[] { Path }; - return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations).ToArray(); + return AdditionalLocations is null ? paths : paths.Concat(AdditionalLocations).ToArray(); } } @@ -130,13 +130,13 @@ namespace MediaBrowser.Controller.Library { var parent = Parent; - if (parent != null) + if (parent is not null) { var item = parent as T; // Just in case the user decided to nest episodes. // Not officially supported but in some cases we can handle it. - if (item == null) + if (item is null) { var parents = parent.GetParents(); foreach (var currentParent in parents) @@ -148,7 +148,7 @@ namespace MediaBrowser.Controller.Library } } - return item != null; + return item is not null; } return false; @@ -171,10 +171,7 @@ namespace MediaBrowser.Controller.Library /// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c> or empty.</exception> public void AddAdditionalLocation(string path) { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentException("The path was empty or null.", nameof(path)); - } + ArgumentException.ThrowIfNullOrEmpty(path); AdditionalLocations ??= new List<string>(); AdditionalLocations.Add(path); @@ -190,10 +187,7 @@ namespace MediaBrowser.Controller.Library /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception> public FileSystemMetadata GetFileSystemEntryByName(string name) { - if (string.IsNullOrEmpty(name)) - { - throw new ArgumentException("The name was empty or null.", nameof(name)); - } + ArgumentException.ThrowIfNullOrEmpty(name); return GetFileSystemEntryByPath(System.IO.Path.Combine(Path, name)); } @@ -206,10 +200,7 @@ namespace MediaBrowser.Controller.Library /// <exception cref="ArgumentNullException">Throws if path is invalid.</exception> public FileSystemMetadata GetFileSystemEntryByPath(string path) { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentException("The path was empty or null.", nameof(path)); - } + ArgumentException.ThrowIfNullOrEmpty(path); foreach (var file in FileSystemChildren) { @@ -287,14 +278,14 @@ namespace MediaBrowser.Controller.Library /// <returns><c>true</c> if the arguments are the same, <c>false</c> otherwise.</returns> protected bool Equals(ItemResolveArgs args) { - if (args != null) + if (args is not null) { - if (args.Path == null && Path == null) + if (args.Path is null && Path is null) { return true; } - return args.Path != null && BaseItem.FileSystem.AreEqual(args.Path, Path); + return args.Path is not null && BaseItem.FileSystem.AreEqual(args.Path, Path); } return false; diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs index 9d78b8b6c..919570e89 100644 --- a/MediaBrowser.Controller/Library/NameExtensions.cs +++ b/MediaBrowser.Controller/Library/NameExtensions.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Library private static string RemoveDiacritics(string? name) { - if (name == null) + if (name is null) { return string.Empty; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 335222da9..978826042 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -139,7 +139,7 @@ namespace MediaBrowser.Controller.LiveTv Path = Path, RunTimeTicks = RunTimeTicks, Type = MediaSourceType.Placeholder, - IsInfiniteStream = RunTimeTicks == null + IsInfiniteStream = RunTimeTicks is null }; list.Add(info); diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 6c4a5ea17..514323238 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -246,7 +246,7 @@ namespace MediaBrowser.Controller.LiveTv var listings = GetListingsProviderInfo(); - if (listings != null) + if (listings is not null) { if (!string.IsNullOrEmpty(listings.MoviePrefix) && name.StartsWith(listings.MoviePrefix, StringComparison.OrdinalIgnoreCase)) { diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index d4e025a43..4a66edb16 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -14,14 +14,14 @@ </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> - <TreatWarningsAsErrors>false</TreatWarningsAsErrors> + <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors> </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> - <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" /> + <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" /> + <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.1" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> - <PackageReference Include="System.Threading.Tasks.Dataflow" Version="6.0.0" /> + <PackageReference Include="System.Threading.Tasks.Dataflow" Version="7.0.0" /> </ItemGroup> <ItemGroup> @@ -35,7 +35,7 @@ </ItemGroup> <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> + <TargetFramework>net7.0</TargetFramework> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateDocumentationFile>true</GenerateDocumentationFile> <PublishRepositoryUrl>true</PublishRepositoryUrl> diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index aa57f0480..7264c5eed 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -162,7 +162,7 @@ namespace MediaBrowser.Controller.MediaEncoding private bool IsHwTonemapAvailable(EncodingJobInfo state, EncodingOptions options) { - if (state.VideoStream == null + if (state.VideoStream is null || !options.EnableTonemapping || GetVideoColorBitDepth(state) != 10) { @@ -189,7 +189,7 @@ namespace MediaBrowser.Controller.MediaEncoding private bool IsVulkanHwTonemapAvailable(EncodingJobInfo state, EncodingOptions options) { - if (state.VideoStream == null) + if (state.VideoStream is null) { return false; } @@ -202,7 +202,7 @@ namespace MediaBrowser.Controller.MediaEncoding private bool IsVaapiVppTonemapAvailable(EncodingJobInfo state, EncodingOptions options) { - if (state.VideoStream == null + if (state.VideoStream is null || !options.EnableVppTonemapping || GetVideoColorBitDepth(state) != 10) { @@ -682,7 +682,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetGraphicalSubCanvasSize(EncodingJobInfo state) { - if (state.SubtitleStream != null + if (state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode && !state.SubtitleStream.IsTextSubtitleStream) { @@ -932,7 +932,7 @@ namespace MediaBrowser.Controller.MediaEncoding .Append(GetInputPathArgument(state)); // sub2video for external graphical subtitles - if (state.SubtitleStream != null + if (state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleStream.IsExternal) @@ -963,7 +963,7 @@ namespace MediaBrowser.Controller.MediaEncoding arg.Append(" -i file:\"").Append(subtitlePath).Append('\"'); } - if (state.AudioStream != null && state.AudioStream.IsExternal) + if (state.AudioStream is not null && state.AudioStream.IsExternal) { // Also seek the external audio stream. var seekAudioParam = GetFastSeekCommandLineParameter(state, options, segmentContainer); @@ -1066,7 +1066,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetVideoBitrateParam(EncodingJobInfo state, string videoCodec) { - if (state.OutputVideoBitrate == null) + if (state.OutputVideoBitrate is null) { return string.Empty; } @@ -1231,7 +1231,7 @@ namespace MediaBrowser.Controller.MediaEncoding var maxrate = request.MaxFramerate; - if (maxrate.HasValue && state.VideoStream != null) + if (maxrate.HasValue && state.VideoStream is not null) { var contentRate = state.VideoStream.AverageFrameRate ?? state.VideoStream.RealFrameRate; @@ -1981,7 +1981,7 @@ namespace MediaBrowser.Controller.MediaEncoding { var bitrate = request.VideoBitRate; - if (videoStream != null) + if (videoStream is not null) { var isUpscaling = request.Height.HasValue && videoStream.Height.HasValue @@ -2076,7 +2076,7 @@ namespace MediaBrowser.Controller.MediaEncoding public int? GetAudioBitrateParam(int? audioBitRate, string audioCodec, MediaStream audioStream) { - if (audioStream == null) + if (audioStream is null) { return null; } @@ -2130,7 +2130,7 @@ namespace MediaBrowser.Controller.MediaEncoding // Boost volume to 200% when downsampling from 6ch to 2ch if (channels.HasValue && channels.Value <= 2 - && state.AudioStream != null + && state.AudioStream is not null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5 && !encodingOptions.DownMixAudioBoost.Equals(1)) @@ -2139,7 +2139,7 @@ namespace MediaBrowser.Controller.MediaEncoding } var isCopyingTimestamps = state.CopyTimestamps || state.TranscodingType != TranscodingJobType.Progressive; - if (state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode && !isCopyingTimestamps) + if (state.SubtitleStream is not null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode && !isCopyingTimestamps) { var seconds = TimeSpan.FromTicks(state.StartTimeTicks ?? 0).TotalSeconds; @@ -2167,7 +2167,7 @@ namespace MediaBrowser.Controller.MediaEncoding /// <returns>System.Nullable{System.Int32}.</returns> public int? GetNumAudioChannelsParam(EncodingJobInfo state, MediaStream audioStream, string outputAudioCodec) { - if (audioStream == null) + if (audioStream is null) { return null; } @@ -2320,26 +2320,26 @@ namespace MediaBrowser.Controller.MediaEncoding // If we don't have known media info // If input is video, use -sn to drop subtitles // Otherwise just return empty - if (state.VideoStream == null && state.AudioStream == null) + if (state.VideoStream is null && state.AudioStream is null) { return state.IsInputVideo ? "-sn" : string.Empty; } // We have media info, but we don't know the stream index - if (state.VideoStream != null && state.VideoStream.Index == -1) + if (state.VideoStream is not null && state.VideoStream.Index == -1) { return "-sn"; } // We have media info, but we don't know the stream index - if (state.AudioStream != null && state.AudioStream.Index == -1) + if (state.AudioStream is not null && state.AudioStream.Index == -1) { return state.IsInputVideo ? "-sn" : string.Empty; } var args = string.Empty; - if (state.VideoStream != null) + if (state.VideoStream is not null) { int videoStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.VideoStream); @@ -2354,12 +2354,12 @@ namespace MediaBrowser.Controller.MediaEncoding args += "-vn"; } - if (state.AudioStream != null) + if (state.AudioStream is not null) { int audioStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.AudioStream); if (state.AudioStream.IsExternal) { - bool hasExternalGraphicsSubs = state.SubtitleStream != null + bool hasExternalGraphicsSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream; @@ -2385,7 +2385,7 @@ namespace MediaBrowser.Controller.MediaEncoding } var subtitleMethod = state.SubtitleDeliveryMethod; - if (state.SubtitleStream == null || subtitleMethod == SubtitleDeliveryMethod.Hls) + if (state.SubtitleStream is null || subtitleMethod == SubtitleDeliveryMethod.Hls) { args += " -map -0:s"; } @@ -2427,7 +2427,7 @@ namespace MediaBrowser.Controller.MediaEncoding { var stream = streams.FirstOrDefault(s => s.Index == desiredIndex.Value); - if (stream != null) + if (stream is not null) { return stream; } @@ -2731,7 +2731,7 @@ namespace MediaBrowser.Controller.MediaEncoding } // default - if (filter == null) + if (filter is null) { if (requestedHeight > 0) { @@ -2814,7 +2814,6 @@ namespace MediaBrowser.Controller.MediaEncoding { algorithm = "bt.2390"; } - else if (string.Equals(options.TonemappingAlgorithm, "none", StringComparison.OrdinalIgnoreCase)) { algorithm = "clip"; @@ -2876,7 +2875,7 @@ namespace MediaBrowser.Controller.MediaEncoding var doDeintHevc = state.DeInterlace("h265", true) || state.DeInterlace("hevc", true); var doDeintH2645 = doDeintH264 || doDeintHevc; - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; @@ -2991,7 +2990,7 @@ namespace MediaBrowser.Controller.MediaEncoding var doDeintH2645 = doDeintH264 || doDeintHevc; var doCuTonemap = IsHwTonemapAvailable(state, options); - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; var hasAssSubs = hasSubs @@ -3181,7 +3180,7 @@ namespace MediaBrowser.Controller.MediaEncoding var doDeintH2645 = doDeintH264 || doDeintHevc; var doOclTonemap = IsHwTonemapAvailable(state, options); - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; var hasAssSubs = hasSubs @@ -3403,7 +3402,7 @@ namespace MediaBrowser.Controller.MediaEncoding var doDeintH2645 = doDeintH264 || doDeintHevc; var doOclTonemap = IsHwTonemapAvailable(state, options); - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; var hasAssSubs = hasSubs @@ -3606,7 +3605,7 @@ namespace MediaBrowser.Controller.MediaEncoding var doTonemap = doVaVppTonemap || doOclTonemap; var doDeintH2645 = doDeintH264 || doDeintHevc; - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; var hasAssSubs = hasSubs @@ -3883,7 +3882,7 @@ namespace MediaBrowser.Controller.MediaEncoding var doTonemap = doVaVppTonemap || doOclTonemap; var doDeintH2645 = doDeintH264 || doDeintHevc; - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; var hasAssSubs = hasSubs @@ -4079,7 +4078,7 @@ namespace MediaBrowser.Controller.MediaEncoding var doVkTonemap = IsVulkanHwTonemapAvailable(state, options); var doDeintH2645 = doDeintH264 || doDeintHevc; - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; var hasAssSubs = hasSubs @@ -4278,7 +4277,7 @@ namespace MediaBrowser.Controller.MediaEncoding var doDeintH2645 = doDeintH264 || doDeintHevc; var doOclTonemap = IsHwTonemapAvailable(state, options); - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; @@ -4441,12 +4440,12 @@ namespace MediaBrowser.Controller.MediaEncoding string outputVideoCodec) { var videoStream = state.VideoStream; - if (videoStream == null) + if (videoStream is null) { return string.Empty; } - var hasSubs = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasSubs = state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream; var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream; @@ -4496,7 +4495,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (overlayFilters?.Count > 0 && subFilters?.Count > 0 - && state.SubtitleStream != null) + && state.SubtitleStream is not null) { // overlay graphical/text subtitles var subStr = string.Format( @@ -4583,7 +4582,7 @@ namespace MediaBrowser.Controller.MediaEncoding public static int GetVideoColorBitDepth(EncodingJobInfo state) { var videoStream = state.VideoStream; - if (videoStream != null) + if (videoStream is not null) { if (videoStream.BitDepth.HasValue) { @@ -4624,7 +4623,7 @@ namespace MediaBrowser.Controller.MediaEncoding { var videoStream = state.VideoStream; var mediaSource = state.MediaSource; - if (videoStream == null || mediaSource == null) + if (videoStream is null || mediaSource is null) { return null; } @@ -5197,7 +5196,7 @@ namespace MediaBrowser.Controller.MediaEncoding #nullable disable public void TryStreamCopy(EncodingJobInfo state) { - if (state.VideoStream != null && CanStreamCopyVideo(state, state.VideoStream)) + if (state.VideoStream is not null && CanStreamCopyVideo(state, state.VideoStream)) { state.OutputVideoCodec = "copy"; } @@ -5206,13 +5205,13 @@ namespace MediaBrowser.Controller.MediaEncoding var user = state.User; // If the user doesn't have access to transcoding, then force stream copy, regardless of whether it will be compatible or not - if (user != null && !user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding)) + if (user is not null && !user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding)) { state.OutputVideoCodec = "copy"; } } - if (state.AudioStream != null + if (state.AudioStream is not null && CanStreamCopyAudio(state, state.AudioStream, state.SupportedAudioCodecs)) { state.OutputAudioCodec = "copy"; @@ -5222,7 +5221,7 @@ namespace MediaBrowser.Controller.MediaEncoding var user = state.User; // If the user doesn't have access to transcoding, then force stream copy, regardless of whether it will be compatible or not - if (user != null && !user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding)) + if (user is not null && !user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding)) { state.OutputAudioCodec = "copy"; } @@ -5419,7 +5418,7 @@ namespace MediaBrowser.Controller.MediaEncoding state.SubtitleDeliveryMethod = videoRequest.SubtitleMethod; state.AudioStream = GetMediaStream(mediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio); - if (state.SubtitleStream != null && !state.SubtitleStream.IsExternal) + if (state.SubtitleStream is not null && !state.SubtitleStream.IsExternal) { state.InternalSubtitleStreamOffset = mediaStreams.Where(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal).ToList().IndexOf(state.SubtitleStream); } @@ -5437,7 +5436,7 @@ namespace MediaBrowser.Controller.MediaEncoding var request = state.BaseRequest; var supportedAudioCodecs = state.SupportedAudioCodecs; - if (request != null && supportedAudioCodecs != null && supportedAudioCodecs.Length > 0) + if (request is not null && supportedAudioCodecs is not null && supportedAudioCodecs.Length > 0) { var supportedAudioCodecsList = supportedAudioCodecs.ToList(); @@ -5450,7 +5449,7 @@ namespace MediaBrowser.Controller.MediaEncoding } var supportedVideoCodecs = state.SupportedVideoCodecs; - if (request != null && supportedVideoCodecs != null && supportedVideoCodecs.Length > 0) + if (request is not null && supportedVideoCodecs is not null && supportedVideoCodecs.Length > 0) { var supportedVideoCodecsList = supportedVideoCodecs.ToList(); @@ -5470,7 +5469,7 @@ namespace MediaBrowser.Controller.MediaEncoding return; } - var inputChannels = audioStream == null ? 6 : audioStream.Channels ?? 6; + var inputChannels = audioStream is null ? 6 : audioStream.Channels ?? 6; if (inputChannels >= 6) { return; @@ -5522,7 +5521,7 @@ namespace MediaBrowser.Controller.MediaEncoding private void NormalizeSubtitleEmbed(EncodingJobInfo state) { - if (state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) + if (state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) { return; } @@ -5537,7 +5536,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetSubtitleEmbedArguments(EncodingJobInfo state) { - if (state.SubtitleStream == null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) + if (state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Embed) { return string.Empty; } @@ -5569,7 +5568,7 @@ namespace MediaBrowser.Controller.MediaEncoding && state.BaseRequest.Context == EncodingContext.Streaming) { // Comparison: https://github.com/jansmolders86/mediacenterjs/blob/master/lib/transcoding/desktop.js - format = " -f mp4 -movflags frag_keyframe+empty_moov"; + format = " -f mp4 -movflags frag_keyframe+empty_moov+delay_moov"; } var threads = GetNumberOfThreads(state, encodingOptions, videoCodec); @@ -5618,7 +5617,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (IsCopyCodec(videoCodec)) { - if (state.VideoStream != null + if (state.VideoStream is not null && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase)) { @@ -5648,7 +5647,7 @@ namespace MediaBrowser.Controller.MediaEncoding args += keyFrameArg; - var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; + var hasGraphicalSubs = state.SubtitleStream is not null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasCopyTs = false; @@ -5668,7 +5667,7 @@ namespace MediaBrowser.Controller.MediaEncoding args += " -avoid_negative_ts disabled"; - if (!(state.SubtitleStream != null && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)) + if (!(state.SubtitleStream is not null && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)) { args += " -start_at_zero"; } @@ -5695,7 +5694,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetProgressiveVideoAudioArguments(EncodingJobInfo state, EncodingOptions encodingOptions) { // If the video doesn't have an audio stream, return a default. - if (state.AudioStream == null && state.VideoStream != null) + if (state.AudioStream is null && state.VideoStream is not null) { return string.Empty; } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index c9625cf1d..179cabc84 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.MediaEncoding { if (!_transcodeReasons.HasValue) { - if (BaseRequest.TranscodeReasons == null) + if (BaseRequest.TranscodeReasons is null) { _transcodeReasons = 0; return 0; @@ -147,7 +147,7 @@ namespace MediaBrowser.Controller.MediaEncoding { get { - if (VideoStream != null && VideoStream.Width.HasValue && VideoStream.Height.HasValue) + if (VideoStream is not null && VideoStream.Width.HasValue && VideoStream.Height.HasValue) { var size = new ImageDimensions(VideoStream.Width.Value, VideoStream.Height.Value); @@ -174,7 +174,7 @@ namespace MediaBrowser.Controller.MediaEncoding { get { - if (VideoStream != null && VideoStream.Width.HasValue && VideoStream.Height.HasValue) + if (VideoStream is not null && VideoStream.Width.HasValue && VideoStream.Height.HasValue) { var size = new ImageDimensions(VideoStream.Width.Value, VideoStream.Height.Value); @@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (BaseRequest.Static || EncodingHelper.IsCopyCodec(OutputAudioCodec)) { - if (AudioStream != null) + if (AudioStream is not null) { return AudioStream.SampleRate; } @@ -227,7 +227,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (BaseRequest.Static || EncodingHelper.IsCopyCodec(OutputAudioCodec)) { - if (AudioStream != null) + if (AudioStream is not null) { return AudioStream.BitDepth; } @@ -305,7 +305,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (BaseRequest.Static || EncodingHelper.IsCopyCodec(OutputVideoCodec)) { - return VideoStream == null ? null : (VideoStream.AverageFrameRate ?? VideoStream.RealFrameRate); + return VideoStream is null ? null : (VideoStream.AverageFrameRate ?? VideoStream.RealFrameRate); } return BaseRequest.MaxFramerate ?? BaseRequest.Framerate; @@ -419,7 +419,7 @@ namespace MediaBrowser.Controller.MediaEncoding { get { - if (VideoStream == null) + if (VideoStream is null) { return null; } @@ -437,7 +437,7 @@ namespace MediaBrowser.Controller.MediaEncoding { get { - if (AudioStream == null) + if (AudioStream is null) { return null; } @@ -556,7 +556,7 @@ namespace MediaBrowser.Controller.MediaEncoding public bool DeInterlace(string videoCodec, bool forceDeinterlaceIfSourceIsInterlaced) { var videoStream = VideoStream; - var isInputInterlaced = videoStream != null && videoStream.IsInterlaced; + var isInputInterlaced = videoStream is not null && videoStream.IsInterlaced; if (!isInputInterlaced) { diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 52c57b906..fe8e9063e 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -38,7 +38,7 @@ namespace MediaBrowser.Controller.MediaEncoding Version EncoderVersion { get; } /// <summary> - /// Whether p key pausing is supported. + /// Gets a value indicating whether p key pausing is supported. /// </summary> /// <value><c>true</c> if p key pausing is supported, <c>false</c> otherwise.</value> bool IsPkeyPauseSupported { get; } diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs index 2fe3a5472..fc9ea37d1 100644 --- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs +++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs @@ -166,7 +166,7 @@ namespace MediaBrowser.Controller.Net var data = await GetDataToSend().ConfigureAwait(false); - if (data != null) + if (data is not null) { await connection.SendAsync( new WebSocketMessage<TReturnDataType> @@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Net { var connection = _activeConnections.FirstOrDefault(c => c.Item1 == message.Connection); - if (connection != null) + if (connection is not null) { DisposeConnection(connection); } diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 7ae9ff746..e6bcc9ea8 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -165,7 +165,7 @@ namespace MediaBrowser.Controller.Playlists public static List<BaseItem> GetPlaylistItems(string playlistMediaType, IEnumerable<BaseItem> inputItems, User user, DtoOptions options) { - if (user != null) + if (user is not null) { inputItems = inputItems.Where(i => i.IsVisible(user)); } diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs index 32a7951f6..7e0a69586 100644 --- a/MediaBrowser.Controller/Providers/IProviderManager.cs +++ b/MediaBrowser.Controller/Providers/IProviderManager.cs @@ -216,7 +216,7 @@ namespace MediaBrowser.Controller.Providers /// <returns>Task{HttpResponseInfo}.</returns> Task<HttpResponseMessage> GetSearchImage(string providerName, string url, CancellationToken cancellationToken); - Dictionary<Guid, Guid> GetRefreshQueue(); + HashSet<Guid> GetRefreshQueue(); void OnRefreshStart(BaseItem item); diff --git a/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs b/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs index 888ca6c72..9ad0c26b0 100644 --- a/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs +++ b/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs @@ -16,6 +16,8 @@ namespace MediaBrowser.Controller.Providers /// <summary> /// Interface IRemoteMetadataProvider. /// </summary> + /// <typeparam name="TItemType">The type of <see cref="BaseItem" />.</typeparam> + /// <typeparam name="TLookupInfoType">The type of <see cref="ItemLookupInfo" />.</typeparam> public interface IRemoteMetadataProvider<TItemType, in TLookupInfoType> : IMetadataProvider<TItemType>, IRemoteMetadataProvider, IRemoteSearchProvider<TLookupInfoType> where TItemType : BaseItem, IHasLookupInfo<TLookupInfoType> where TLookupInfoType : ItemLookupInfo, new() @@ -32,6 +34,7 @@ namespace MediaBrowser.Controller.Providers /// <summary> /// Interface IRemoteMetadataProvider. /// </summary> + /// <typeparam name="TLookupInfoType">The type of <see cref="ItemLookupInfo" />.</typeparam> public interface IRemoteSearchProvider<in TLookupInfoType> : IRemoteSearchProvider where TLookupInfoType : ItemLookupInfo { diff --git a/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs b/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs index a38bbaf69..8a3709462 100644 --- a/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs +++ b/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Providers SearchResult = copy.SearchResult; RemoveOldMetadata = copy.RemoveOldMetadata; - if (copy.RefreshPaths != null && copy.RefreshPaths.Length > 0) + if (copy.RefreshPaths is not null && copy.RefreshPaths.Length > 0) { RefreshPaths ??= Array.Empty<string>(); @@ -58,7 +58,7 @@ namespace MediaBrowser.Controller.Providers public bool RefreshItem(BaseItem item) { - if (RefreshPaths != null && RefreshPaths.Length > 0) + if (RefreshPaths is not null && RefreshPaths.Length > 0) { return RefreshPaths.Contains(item.Path ?? string.Empty, StringComparison.OrdinalIgnoreCase); } diff --git a/MediaBrowser.Controller/Providers/MetadataResult.cs b/MediaBrowser.Controller/Providers/MetadataResult.cs index 58a0fa2a9..952dd4870 100644 --- a/MediaBrowser.Controller/Providers/MetadataResult.cs +++ b/MediaBrowser.Controller/Providers/MetadataResult.cs @@ -59,7 +59,7 @@ namespace MediaBrowser.Controller.Providers /// </summary> public void ResetPeople() { - if (People == null) + if (People is null) { People = new List<PersonInfo>(); } @@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Providers } } - if (userData == null) + if (userData is null) { userData = new UserItemData() { diff --git a/MediaBrowser.Controller/Resolvers/ItemResolver.cs b/MediaBrowser.Controller/Resolvers/ItemResolver.cs index e7bf013fa..a6da8384e 100644 --- a/MediaBrowser.Controller/Resolvers/ItemResolver.cs +++ b/MediaBrowser.Controller/Resolvers/ItemResolver.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Resolvers { var item = Resolve(args); - if (item != null) + if (item is not null) { SetInitialItemValues(item, args); } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index b4520ae48..25bf23d61 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -64,7 +64,7 @@ namespace MediaBrowser.Controller.Session { get { - if (Capabilities == null) + if (Capabilities is null) { return Array.Empty<string>(); } @@ -182,7 +182,7 @@ namespace MediaBrowser.Controller.Session { get { - if (Capabilities == null || !Capabilities.SupportsMediaControl) + if (Capabilities is null || !Capabilities.SupportsMediaControl) { return false; } @@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Session { get { - if (Capabilities == null || !Capabilities.SupportsMediaControl) + if (Capabilities is null || !Capabilities.SupportsMediaControl) { return false; } @@ -239,7 +239,7 @@ namespace MediaBrowser.Controller.Session /// </summary> /// <value>The supported commands.</value> public IReadOnlyList<GeneralCommandType> SupportedCommands - => Capabilities == null ? Array.Empty<GeneralCommandType>() : Capabilities.SupportedCommands; + => Capabilities is null ? Array.Empty<GeneralCommandType>() : Capabilities.SupportedCommands; public Tuple<ISessionController, bool> EnsureController<T>(Func<SessionInfo, ISessionController> factory) { @@ -296,7 +296,7 @@ namespace MediaBrowser.Controller.Session { _lastProgressInfo = progressInfo; - if (_progressTimer == null) + if (_progressTimer is null) { _progressTimer = new Timer(OnProgressTimerCallback, null, 1000, 1000); } @@ -315,7 +315,7 @@ namespace MediaBrowser.Controller.Session } var progressInfo = _lastProgressInfo; - if (progressInfo == null) + if (progressInfo is null) { return; } @@ -357,7 +357,7 @@ namespace MediaBrowser.Controller.Session { lock (_progressLock) { - if (_progressTimer != null) + if (_progressTimer is not null) { _progressTimer.Dispose(); _progressTimer = null; diff --git a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs index 3a7685f34..ddbfeb8de 100644 --- a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs +++ b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs @@ -180,7 +180,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue _shuffledPlaylist.Clear(); LastChange = DateTime.UtcNow; - if (!clearPlayingItem && playingItem != null) + if (!clearPlayingItem && playingItem is not null) { _sortedPlaylist.Add(playingItem); if (ShuffleMode.Equals(GroupShuffleMode.Shuffle)) @@ -298,7 +298,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue LastChange = DateTime.UtcNow; - if (playingItem != null) + if (playingItem is not null) { if (playlistItemIds.Contains(playingItem.PlaylistItemId)) { |
