diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index ae3577b7d02..ed1fe879175 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -2,7 +2,6 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 07b8185c5c3..ed31cbd1d85 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -55,12 +55,11 @@ public string GetHeader(string name) return Request.Headers[name]; } - private static readonly string[] EmptyStringArray = Array.Empty(); public static string[] SplitValue(string value, char delim) { if (string.IsNullOrWhiteSpace(value)) { - return EmptyStringArray; + return Array.Empty(); } return value.Split(new[] { delim }, StringSplitOptions.RemoveEmptyEntries); diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 29f3070a590..913a55b2b32 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Authentication; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; @@ -10,11 +11,9 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Users; using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; -using MediaBrowser.Controller.Authentication; namespace MediaBrowser.Api { diff --git a/MediaBrowser.Controller/Authentication/IAuthenticationProvider.cs b/MediaBrowser.Controller/Authentication/IAuthenticationProvider.cs index becb3ea627a..82308296f1f 100644 --- a/MediaBrowser.Controller/Authentication/IAuthenticationProvider.cs +++ b/MediaBrowser.Controller/Authentication/IAuthenticationProvider.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; +using System.Threading.Tasks; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Users; diff --git a/MediaBrowser.Controller/Chapters/IChapterManager.cs b/MediaBrowser.Controller/Chapters/IChapterManager.cs index 2a20eb365d6..161e87094ab 100644 --- a/MediaBrowser.Controller/Chapters/IChapterManager.cs +++ b/MediaBrowser.Controller/Chapters/IChapterManager.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Threading.Tasks; using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Chapters @@ -9,12 +8,6 @@ namespace MediaBrowser.Controller.Chapters /// public interface IChapterManager { - /// - /// Gets the chapters. - /// - /// The item identifier. - /// List{ChapterInfo}. - /// /// Saves the chapters. /// diff --git a/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs b/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs index 727b487a799..5363e035c3e 100644 --- a/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs +++ b/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs @@ -20,8 +20,8 @@ public class CollectionCreationOptions : IHasProviderIds public CollectionCreationOptions() { ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - ItemIdList = new string[] {}; - UserIds = new Guid[] {}; + ItemIdList = Array.Empty(); + UserIds = Array.Empty(); } } } diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs deleted file mode 100644 index 8ac61bf2b19..00000000000 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ /dev/null @@ -1,45 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Connect; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace MediaBrowser.Controller.Connect -{ - public interface IConnectManager - { - /// - /// Gets the wan API address. - /// - /// The wan API address. - string WanApiAddress { get; } - - /// - /// Links the user. - /// - /// The user identifier. - /// The connect username. - /// Task. - Task LinkUser(string userId, string connectUsername); - - /// - /// Removes the link. - /// - /// The user identifier. - /// Task. - Task RemoveConnect(string userId); - - User GetUserFromExchangeToken(string token); - - /// - /// Authenticates the specified username. - /// - Task Authenticate(string username, string password, string passwordMd5); - - /// - /// Determines whether [is authorization token valid] [the specified token]. - /// - /// The token. - /// true if [is authorization token valid] [the specified token]; otherwise, false. - bool IsAuthorizationTokenValid(string token); - } -} diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index 219b367891d..37e83e45a21 100644 --- a/MediaBrowser.Controller/Dto/IDtoService.cs +++ b/MediaBrowser.Controller/Dto/IDtoService.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using System.Collections.Generic; -using MediaBrowser.Controller.Sync; namespace MediaBrowser.Controller.Dto { diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 4f4b3483cf7..a4601c270d6 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -20,7 +20,7 @@ public class AggregateFolder : Folder { public AggregateFolder() { - PhysicalLocationsList = new string[] { }; + PhysicalLocationsList = Array.Empty(); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index d07e31d8a46..1aeae6052f3 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -2,13 +2,8 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading; -using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Serialization; @@ -36,8 +31,8 @@ public class Audio : BaseItem, public Audio() { - Artists = new string[] {}; - AlbumArtists = new string[] {}; + Artists = Array.Empty(); + AlbumArtists = Array.Empty(); } public override double GetDefaultPrimaryImageAspectRatio() diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 48b5c64b21f..870e6e07e14 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -23,8 +23,8 @@ public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres, public MusicAlbum() { - Artists = new string[] {}; - AlbumArtists = new string[] {}; + Artists = Array.Empty(); + AlbumArtists = Array.Empty(); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 2774dc9443c..56ed10ced64 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -129,13 +129,12 @@ public override bool IsSaveLocalMetadataEnabled() return base.IsSaveLocalMetadataEnabled(); } - private readonly Task _cachedTask = Task.FromResult(true); protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { if (IsAccessedByName) { // Should never get in here anyway - return _cachedTask; + return Task.CompletedTask; } return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index e80fe33875c..a268e6d765c 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -35,24 +35,24 @@ namespace MediaBrowser.Controller.Entities /// public abstract class BaseItem : IHasProviderIds, IHasLookupInfo { - protected static MetadataFields[] EmptyMetadataFieldsArray = new MetadataFields[] { }; - protected static MediaUrl[] EmptyMediaUrlArray = new MediaUrl[] { }; - protected static ItemImageInfo[] EmptyItemImageInfoArray = new ItemImageInfo[] { }; - public static readonly LinkedChild[] EmptyLinkedChildArray = new LinkedChild[] { }; + protected static MetadataFields[] EmptyMetadataFieldsArray = Array.Empty(); + protected static MediaUrl[] EmptyMediaUrlArray = Array.Empty(); + protected static ItemImageInfo[] EmptyItemImageInfoArray = Array.Empty(); + public static readonly LinkedChild[] EmptyLinkedChildArray = Array.Empty(); protected BaseItem() { - ThemeSongIds = new Guid[] {}; - ThemeVideoIds = new Guid[] {}; - Tags = new string[] {}; - Genres = new string[] {}; - Studios = new string[] {}; + ThemeSongIds = Array.Empty(); + ThemeVideoIds = Array.Empty(); + Tags = Array.Empty(); + Genres = Array.Empty(); + Studios = Array.Empty(); ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); LockedFields = EmptyMetadataFieldsArray; ImageInfos = EmptyItemImageInfoArray; - ProductionLocations = new string[] {}; - RemoteTrailers = new MediaUrl[] { }; - ExtraIds = new Guid[] {}; + ProductionLocations = Array.Empty(); + RemoteTrailers = Array.Empty(); + ExtraIds = Array.Empty(); } public static readonly char[] SlugReplaceChars = { '?', '/', '&' }; @@ -62,7 +62,6 @@ protected BaseItem() /// The supported image extensions /// public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg", ".tbn", ".gif" }; - public static readonly List SupportedImageExtensionsList = SupportedImageExtensions.ToList(); /// /// The trailer folder name @@ -2895,6 +2894,10 @@ public IEnumerable GetThemeVideos() return ThemeVideoIds.Select(LibraryManager.GetItemById).Where(i => i.ExtraType.Equals(Model.Entities.ExtraType.ThemeVideo)).OrderBy(i => i.SortName); } + /// + /// Gets or sets the remote trailers. + /// + /// The remote trailers. public MediaUrl[] RemoteTrailers { get; set; } public IEnumerable GetExtras() @@ -2913,21 +2916,24 @@ public IEnumerable GetDisplayExtras() } public virtual bool IsHD { - get{ + get + { return Height >= 720; - } + } } public bool IsShortcut{ get; set;} public string ShortcutPath{ get; set;} public int Width { get; set; } public int Height { get; set; } public Guid[] ExtraIds { get; set; } - public virtual long GetRunTimeTicksForPlayState() { + public virtual long GetRunTimeTicksForPlayState() + { return RunTimeTicks ?? 0; } // what does this do? public static ExtraType[] DisplayExtraTypes = new[] {Model.Entities.ExtraType.ThemeSong, Model.Entities.ExtraType.ThemeVideo }; - public virtual bool SupportsExternalTransfer { + public virtual bool SupportsExternalTransfer + { get { return false; } diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 7292b166a07..75d6b938180 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -31,18 +31,10 @@ public class CollectionFolder : Folder, ICollectionFolder public CollectionFolder() { - PhysicalLocationsList = new string[] { }; - PhysicalFolderIds = new Guid[] { }; + PhysicalLocationsList = Array.Empty(); + PhysicalFolderIds = Array.Empty(); } - //public override double? GetDefaultPrimaryImageAspectRatio() - //{ - // double value = 16; - // value /= 9; - - // return value; - //} - [IgnoreDataMember] public override bool SupportsPlayedStatus { @@ -339,7 +331,7 @@ private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bo /// Task. protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { - return Task.FromResult(true); + return Task.CompletedTask; } /// diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index 3d006a699c5..4efc5648ea9 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -12,10 +12,10 @@ public class Game : BaseItem, IHasTrailers, IHasScreenshots, ISupportsPlaceHolde { public Game() { - MultiPartGameFiles = new string[] {}; + MultiPartGameFiles = Array.Empty(); RemoteTrailers = EmptyMediaUrlArray; - LocalTrailerIds = new Guid[] {}; - RemoteTrailerIds = new Guid[] {}; + LocalTrailerIds = Array.Empty(); + RemoteTrailerIds = Array.Empty(); } public Guid[] LocalTrailerIds { get; set; } @@ -38,12 +38,6 @@ public override bool SupportsPeople get { return false; } } - /// - /// Gets or sets the remote trailers. - /// - /// The remote trailers. - public MediaUrl[] RemoteTrailers { get; set; } - /// /// Gets the type of the media. /// diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index ff57c247140..bb99c0a84eb 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -4,7 +4,6 @@ using MediaBrowser.Model.Configuration; using System.Linq; using MediaBrowser.Controller.Dto; -using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Entities { @@ -48,7 +47,6 @@ public class InternalItemsQuery public string PresentationUniqueKey { get; set; } public string Path { get; set; } - public string PathNotStartsWith { get; set; } public string Name { get; set; } public string Person { get; set; } @@ -160,8 +158,6 @@ public BaseItem Parent public bool EnableGroupByMetadataKey { get; set; } public bool? HasChapterImages { get; set; } - // why tuple vs value tuple? - //public Tuple[] OrderBy { get; set; } public ValueTuple[] OrderBy { get; set; } public DateTime? MinDateCreated { get; set; } @@ -180,44 +176,44 @@ public BaseItem Parent public InternalItemsQuery() { - AlbumArtistIds = new Guid[] {}; - AlbumIds = new Guid[] {}; - AncestorIds = new Guid[] {}; - ArtistIds = new Guid[] {}; - BlockUnratedItems = new UnratedItem[] { }; - BoxSetLibraryFolders = new Guid[] {}; - ChannelIds = new Guid[] {}; - ContributingArtistIds = new Guid[] {}; + AlbumArtistIds = Array.Empty(); + AlbumIds = Array.Empty(); + AncestorIds = Array.Empty(); + ArtistIds = Array.Empty(); + BlockUnratedItems = Array.Empty(); + BoxSetLibraryFolders = Array.Empty(); + ChannelIds = Array.Empty(); + ContributingArtistIds = Array.Empty(); DtoOptions = new DtoOptions(); EnableTotalRecordCount = true; - ExcludeArtistIds = new Guid[] {}; - ExcludeInheritedTags = new string[] {}; - ExcludeItemIds = new Guid[] {}; - ExcludeItemTypes = new string[] {}; + ExcludeArtistIds = Array.Empty(); + ExcludeInheritedTags = Array.Empty(); + ExcludeItemIds = Array.Empty(); + ExcludeItemTypes = Array.Empty(); ExcludeProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - ExcludeTags = new string[] {}; - GenreIds = new Guid[] {}; - Genres = new string[] {}; + ExcludeTags = Array.Empty(); + GenreIds = Array.Empty(); + Genres = Array.Empty(); GroupByPresentationUniqueKey = true; HasAnyProviderId = new Dictionary(StringComparer.OrdinalIgnoreCase); - ImageTypes = new ImageType[] { }; - IncludeItemTypes = new string[] {}; - ItemIds = new Guid[] {}; - MediaTypes = new string[] {}; + ImageTypes = Array.Empty(); + IncludeItemTypes = Array.Empty(); + ItemIds = Array.Empty(); + MediaTypes = Array.Empty(); MinSimilarityScore = 20; - OfficialRatings = new string[] {}; + OfficialRatings = Array.Empty(); OrderBy = Array.Empty>(); - PersonIds = new Guid[] {}; - PersonTypes = new string[] {}; - PresetViews = new string[] {}; - SeriesStatuses = new SeriesStatus[] { }; - SourceTypes = new SourceType[] { }; - StudioIds = new Guid[] {}; - Tags = new string[] {}; - TopParentIds = new Guid[] {}; - TrailerTypes = new TrailerType[] { }; - VideoTypes = new VideoType[] { }; - Years = new int[] { }; + PersonIds = Array.Empty(); + PersonTypes = Array.Empty(); + PresetViews = Array.Empty(); + SeriesStatuses = Array.Empty(); + SourceTypes = Array.Empty(); + StudioIds = Array.Empty(); + Tags = Array.Empty(); + TopParentIds = Array.Empty(); + TrailerTypes = Array.Empty(); + VideoTypes = Array.Empty(); + Years = Array.Empty(); } public InternalItemsQuery(User user) diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs index 7e00834e309..ce3e9e070e6 100644 --- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -14,8 +14,8 @@ public class InternalPeopleQuery public InternalPeopleQuery() { - PersonTypes = new string[] { }; - ExcludePersonTypes = new string[] { }; + PersonTypes = Array.Empty(); + ExcludePersonTypes = Array.Empty(); } } } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 5918bf98118..e888a558251 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -19,8 +19,8 @@ public class BoxSet : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo(); + RemoteTrailerIds = Array.Empty(); DisplayOrder = ItemSortBy.PremiereDate; } @@ -52,12 +52,6 @@ public override bool SupportsPeople public Guid[] LocalTrailerIds { get; set; } public Guid[] RemoteTrailerIds { get; set; } - /// - /// Gets or sets the remote trailers. - /// - /// The remote trailers. - public MediaUrl[] RemoteTrailers { get; set; } - /// /// Gets or sets the display order. /// @@ -70,12 +64,7 @@ protected override bool GetBlockUnratedValue(UserPolicy config) } public override double GetDefaultPrimaryImageAspectRatio() - { - double value = 2; - value /= 3; - - return value; - } + => 2 / 3; public override UnratedItem GetBlockUnratedType() { @@ -254,7 +243,7 @@ private IEnumerable FlattenItems(BaseItem item, List expandedFol return FlattenItems(boxset.GetLinkedChildren(), expandedFolders); } - return new BaseItem[] { }; + return Array.Empty(); } return new[] { item }; diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 878b1b860fc..4f743991bc8 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -6,8 +6,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; @@ -32,8 +30,6 @@ public Movie() public Guid[] LocalTrailerIds { get; set; } public Guid[] RemoteTrailerIds { get; set; } - public MediaUrl[] RemoteTrailers { get; set; } - /// /// Gets or sets the name of the TMDB collection. /// @@ -55,10 +51,7 @@ public override double GetDefaultPrimaryImageAspectRatio() return 0; } - double value = 2; - value /= 3; - - return value; + return 2 / 3; } protected override async Task RefreshedOwnedItems(MetadataRefreshOptions options, List fileSystemChildren, CancellationToken cancellationToken) diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 78f9d067183..4015a11780f 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -14,7 +14,7 @@ public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasLookupInfo(); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Photo.cs b/MediaBrowser.Controller/Entities/Photo.cs index 01c10831dc0..662aa42495b 100644 --- a/MediaBrowser.Controller/Entities/Photo.cs +++ b/MediaBrowser.Controller/Entities/Photo.cs @@ -58,6 +58,7 @@ public override bool CanDownload() public override double GetDefaultPrimaryImageAspectRatio() { + // REVIEW: @bond if (Width.HasValue && Height.HasValue) { double width = Width.Value; @@ -85,8 +86,8 @@ public override double GetDefaultPrimaryImageAspectRatio() return base.GetDefaultPrimaryImageAspectRatio(); } - public int? Width { get; set; } - public int? Height { get; set; } + public new int? Width { get; set; } + public new int? Height { get; set; } public string CameraMake { get; set; } public string CameraModel { get; set; } public string Software { get; set; } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 3a3a902a35b..00e055c51a0 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Providers; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using System; @@ -19,13 +19,12 @@ public class Episode : Video, IHasTrailers, IHasLookupInfo, IHasSer public Episode() { RemoteTrailers = EmptyMediaUrlArray; - LocalTrailerIds = new Guid[] {}; - RemoteTrailerIds = new Guid[] {}; + LocalTrailerIds = Array.Empty(); + RemoteTrailerIds = Array.Empty(); } public Guid[] LocalTrailerIds { get; set; } public Guid[] RemoteTrailerIds { get; set; } - public MediaUrl[] RemoteTrailers { get; set; } /// /// Gets the season in which it aired. @@ -112,10 +111,7 @@ public override double GetDefaultPrimaryImageAspectRatio() return 0; } - double value = 16; - value /= 9; - - return value; + return 16 / 9; } public override List GetUserDataKeys() diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index b5f77df55a3..cb3a7f34588 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -102,10 +102,11 @@ public Series Series get { var seriesId = SeriesId; - if (seriesId.Equals(Guid.Empty)) { + if (seriesId == Guid.Empty) + { seriesId = FindSeriesId(); } - return !seriesId.Equals(Guid.Empty) ? (LibraryManager.GetItemById(seriesId) as Series) : null; + return seriesId == Guid.Empty ? null : (LibraryManager.GetItemById(seriesId) as Series); } } @@ -227,7 +228,7 @@ public string FindSeriesName() public Guid FindSeriesId() { var series = FindParent(); - return series == null ? Guid.Empty: series.Id; + return series == null ? Guid.Empty : series.Id; } /// diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 88fde176080..d4a62626ed2 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -23,9 +23,9 @@ public class Series : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo(); + RemoteTrailerIds = Array.Empty(); + AirDays = Array.Empty(); } public DayOfWeek[] AirDays { get; set; } @@ -73,8 +73,6 @@ public override bool SupportsPeople public Guid[] LocalTrailerIds { get; set; } public Guid[] RemoteTrailerIds { get; set; } - public MediaUrl[] RemoteTrailers { get; set; } - /// /// airdate, dvd or absolute /// diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 4f2a5631bfb..2ef268ed18a 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -15,18 +15,13 @@ public class Trailer : Video, IHasLookupInfo { public Trailer() { - TrailerTypes = new TrailerType[] { }; + TrailerTypes = Array.Empty(); } public TrailerType[] TrailerTypes { get; set; } public override double GetDefaultPrimaryImageAspectRatio() - { - double value = 2; - value /= 3; - - return value; - } + => 2 / 3; public override UnratedItem GetBlockUnratedType() { diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index 984cad481e8..b7c9884ff14 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -1,21 +1,18 @@ using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.TV; -using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using System; using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; -using MediaBrowser.Controller.Dto; -using MediaBrowser.Controller.Collections; namespace MediaBrowser.Controller.Entities { public class UserView : Folder, IHasCollectionType { public string ViewType { get; set; } - public Guid DisplayParentId { get; set; } + public new Guid DisplayParentId { get; set; } public Guid? UserId { get; set; } @@ -68,14 +65,6 @@ public override bool SupportsPlayedStatus } } - //public override double? GetDefaultPrimaryImageAspectRatio() - //{ - // double value = 16; - // value /= 9; - - // return value; - //} - public override int GetChildCount(User user) { return GetChildren(user, true).Count; @@ -161,8 +150,8 @@ public static bool IsUserSpecific(Folder folder) public static bool IsEligibleForGrouping(Folder folder) { - var collectionFolder = folder as ICollectionFolder; - return collectionFolder != null && IsEligibleForGrouping(collectionFolder.CollectionType); + return folder is ICollectionFolder collectionFolder + && IsEligibleForGrouping(collectionFolder.CollectionType); } private static string[] ViewTypesEligibleForGrouping = new string[] @@ -195,7 +184,7 @@ public static bool EnableOriginalFolder(string viewType) protected override Task ValidateChildrenInternal(IProgress progress, System.Threading.CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService) { - return Task.FromResult(true); + return Task.CompletedTask; } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 65f5b8382d9..2db200ee27f 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -10,7 +10,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Common.Extensions; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Extensions; @@ -132,8 +131,6 @@ public override bool SupportsThemeMedia public bool HasSubtitles { get; set; } public bool IsPlaceHolder { get; set; } - public bool IsShortcut { get; set; } - public string ShortcutPath { get; set; } /// /// Gets or sets the default index of the video stream. @@ -173,7 +170,7 @@ public string[] GetPlayableStreamFileNames(IMediaEncoder mediaEncoder) } else { - return new string[] {}; + return Array.Empty(); } return mediaEncoder.GetPlayableStreamFileNames(Path, videoType); } @@ -186,9 +183,9 @@ public string[] GetPlayableStreamFileNames(IMediaEncoder mediaEncoder) public Video() { - AdditionalParts = new string[] {}; - LocalAlternateVersions = new string[] {}; - SubtitleFiles = new string[] {}; + AdditionalParts = Array.Empty(); + LocalAlternateVersions = Array.Empty(); + SubtitleFiles = Array.Empty(); LinkedAlternateVersions = EmptyLinkedChildArray; } @@ -215,10 +212,10 @@ public int MediaSourceCount { if (!string.IsNullOrEmpty(PrimaryVersionId)) { - var item = LibraryManager.GetItemById(PrimaryVersionId) as Video; - if (item != null) + var item = LibraryManager.GetItemById(PrimaryVersionId); + if (item is Video video) { - return item.MediaSourceCount; + return video.MediaSourceCount; } } return LinkedAlternateVersions.Length + LocalAlternateVersions.Length + 1; @@ -366,7 +363,7 @@ public IEnumerable /// IEnumerable{Video}. - public IEnumerable