Post GPL cleanup

This commit is contained in:
Bond_009
2018-12-27 22:43:48 +01:00
parent c6618d0a5f
commit 340a2c6512
99 changed files with 327 additions and 1053 deletions

View File

@@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities
{
public AggregateFolder()
{
PhysicalLocationsList = new string[] { };
PhysicalLocationsList = Array.Empty<string>();
}
[IgnoreDataMember]

View File

@@ -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 @@ namespace MediaBrowser.Controller.Entities.Audio
public Audio()
{
Artists = new string[] {};
AlbumArtists = new string[] {};
Artists = Array.Empty<string>();
AlbumArtists = Array.Empty<string>();
}
public override double GetDefaultPrimaryImageAspectRatio()

View File

@@ -23,8 +23,8 @@ namespace MediaBrowser.Controller.Entities.Audio
public MusicAlbum()
{
Artists = new string[] {};
AlbumArtists = new string[] {};
Artists = Array.Empty<string>();
AlbumArtists = Array.Empty<string>();
}
[IgnoreDataMember]

View File

@@ -129,13 +129,12 @@ namespace MediaBrowser.Controller.Entities.Audio
return base.IsSaveLocalMetadataEnabled();
}
private readonly Task _cachedTask = Task.FromResult(true);
protected override Task ValidateChildrenInternal(IProgress<double> 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);

View File

@@ -35,24 +35,24 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo>
{
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<MetadataFields>();
protected static MediaUrl[] EmptyMediaUrlArray = Array.Empty<MediaUrl>();
protected static ItemImageInfo[] EmptyItemImageInfoArray = Array.Empty<ItemImageInfo>();
public static readonly LinkedChild[] EmptyLinkedChildArray = Array.Empty<LinkedChild>();
protected BaseItem()
{
ThemeSongIds = new Guid[] {};
ThemeVideoIds = new Guid[] {};
Tags = new string[] {};
Genres = new string[] {};
Studios = new string[] {};
ThemeSongIds = Array.Empty<Guid>();
ThemeVideoIds = Array.Empty<Guid>();
Tags = Array.Empty<string>();
Genres = Array.Empty<string>();
Studios = Array.Empty<string>();
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
LockedFields = EmptyMetadataFieldsArray;
ImageInfos = EmptyItemImageInfoArray;
ProductionLocations = new string[] {};
RemoteTrailers = new MediaUrl[] { };
ExtraIds = new Guid[] {};
ProductionLocations = Array.Empty<string>();
RemoteTrailers = Array.Empty<MediaUrl>();
ExtraIds = Array.Empty<Guid>();
}
public static readonly char[] SlugReplaceChars = { '?', '/', '&' };
@@ -62,7 +62,6 @@ namespace MediaBrowser.Controller.Entities
/// The supported image extensions
/// </summary>
public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg", ".tbn", ".gif" };
public static readonly List<string> SupportedImageExtensionsList = SupportedImageExtensions.ToList();
/// <summary>
/// The trailer folder name
@@ -2895,6 +2894,10 @@ namespace MediaBrowser.Controller.Entities
return ThemeVideoIds.Select(LibraryManager.GetItemById).Where(i => i.ExtraType.Equals(Model.Entities.ExtraType.ThemeVideo)).OrderBy(i => i.SortName);
}
/// <summary>
/// Gets or sets the remote trailers.
/// </summary>
/// <value>The remote trailers.</value>
public MediaUrl[] RemoteTrailers { get; set; }
public IEnumerable<BaseItem> GetExtras()
@@ -2913,21 +2916,24 @@ namespace MediaBrowser.Controller.Entities
}
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;
}

View File

@@ -31,18 +31,10 @@ namespace MediaBrowser.Controller.Entities
public CollectionFolder()
{
PhysicalLocationsList = new string[] { };
PhysicalFolderIds = new Guid[] { };
PhysicalLocationsList = Array.Empty<string>();
PhysicalFolderIds = Array.Empty<Guid>();
}
//public override double? GetDefaultPrimaryImageAspectRatio()
//{
// double value = 16;
// value /= 9;
// return value;
//}
[IgnoreDataMember]
public override bool SupportsPlayedStatus
{
@@ -339,7 +331,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task.</returns>
protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
{
return Task.FromResult(true);
return Task.CompletedTask;
}
/// <summary>

View File

@@ -12,10 +12,10 @@ namespace MediaBrowser.Controller.Entities
{
public Game()
{
MultiPartGameFiles = new string[] {};
MultiPartGameFiles = Array.Empty<string>();
RemoteTrailers = EmptyMediaUrlArray;
LocalTrailerIds = new Guid[] {};
RemoteTrailerIds = new Guid[] {};
LocalTrailerIds = Array.Empty<Guid>();
RemoteTrailerIds = Array.Empty<Guid>();
}
public Guid[] LocalTrailerIds { get; set; }
@@ -38,12 +38,6 @@ namespace MediaBrowser.Controller.Entities
get { return false; }
}
/// <summary>
/// Gets or sets the remote trailers.
/// </summary>
/// <value>The remote trailers.</value>
public MediaUrl[] RemoteTrailers { get; set; }
/// <summary>
/// Gets the type of the media.
/// </summary>

View File

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using MediaBrowser.Model.Configuration;
using System.Linq;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Controller.Entities
{
@@ -48,7 +47,6 @@ namespace MediaBrowser.Controller.Entities
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 @@ namespace MediaBrowser.Controller.Entities
public bool EnableGroupByMetadataKey { get; set; }
public bool? HasChapterImages { get; set; }
// why tuple vs value tuple?
//public Tuple<string, SortOrder>[] OrderBy { get; set; }
public ValueTuple<string, SortOrder>[] OrderBy { get; set; }
public DateTime? MinDateCreated { get; set; }
@@ -180,44 +176,44 @@ namespace MediaBrowser.Controller.Entities
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<Guid>();
AlbumIds = Array.Empty<Guid>();
AncestorIds = Array.Empty<Guid>();
ArtistIds = Array.Empty<Guid>();
BlockUnratedItems = Array.Empty<UnratedItem>();
BoxSetLibraryFolders = Array.Empty<Guid>();
ChannelIds = Array.Empty<Guid>();
ContributingArtistIds = Array.Empty<Guid>();
DtoOptions = new DtoOptions();
EnableTotalRecordCount = true;
ExcludeArtistIds = new Guid[] {};
ExcludeInheritedTags = new string[] {};
ExcludeItemIds = new Guid[] {};
ExcludeItemTypes = new string[] {};
ExcludeArtistIds = Array.Empty<Guid>();
ExcludeInheritedTags = Array.Empty<string>();
ExcludeItemIds = Array.Empty<Guid>();
ExcludeItemTypes = Array.Empty<string>();
ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
ExcludeTags = new string[] {};
GenreIds = new Guid[] {};
Genres = new string[] {};
ExcludeTags = Array.Empty<string>();
GenreIds = Array.Empty<Guid>();
Genres = Array.Empty<string>();
GroupByPresentationUniqueKey = true;
HasAnyProviderId = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
ImageTypes = new ImageType[] { };
IncludeItemTypes = new string[] {};
ItemIds = new Guid[] {};
MediaTypes = new string[] {};
ImageTypes = Array.Empty<ImageType>();
IncludeItemTypes = Array.Empty<string>();
ItemIds = Array.Empty<Guid>();
MediaTypes = Array.Empty<string>();
MinSimilarityScore = 20;
OfficialRatings = new string[] {};
OfficialRatings = Array.Empty<string>();
OrderBy = Array.Empty<ValueTuple<string, SortOrder>>();
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<Guid>();
PersonTypes = Array.Empty<string>();
PresetViews = Array.Empty<string>();
SeriesStatuses = Array.Empty<SeriesStatus>();
SourceTypes = Array.Empty<SourceType>();
StudioIds = Array.Empty<Guid>();
Tags = Array.Empty<string>();
TopParentIds = Array.Empty<Guid>();
TrailerTypes = Array.Empty<TrailerType>();
VideoTypes = Array.Empty<VideoType>();
Years = Array.Empty<int>();
}
public InternalItemsQuery(User user)

View File

@@ -14,8 +14,8 @@ namespace MediaBrowser.Controller.Entities
public InternalPeopleQuery()
{
PersonTypes = new string[] { };
ExcludePersonTypes = new string[] { };
PersonTypes = Array.Empty<string>();
ExcludePersonTypes = Array.Empty<string>();
}
}
}

View File

@@ -19,8 +19,8 @@ namespace MediaBrowser.Controller.Entities.Movies
public BoxSet()
{
RemoteTrailers = EmptyMediaUrlArray;
LocalTrailerIds = new Guid[] { };
RemoteTrailerIds = new Guid[] { };
LocalTrailerIds = Array.Empty<Guid>();
RemoteTrailerIds = Array.Empty<Guid>();
DisplayOrder = ItemSortBy.PremiereDate;
}
@@ -52,12 +52,6 @@ namespace MediaBrowser.Controller.Entities.Movies
public Guid[] LocalTrailerIds { get; set; }
public Guid[] RemoteTrailerIds { get; set; }
/// <summary>
/// Gets or sets the remote trailers.
/// </summary>
/// <value>The remote trailers.</value>
public MediaUrl[] RemoteTrailers { get; set; }
/// <summary>
/// Gets or sets the display order.
/// </summary>
@@ -70,12 +64,7 @@ namespace MediaBrowser.Controller.Entities.Movies
}
public override double GetDefaultPrimaryImageAspectRatio()
{
double value = 2;
value /= 3;
return value;
}
=> 2 / 3;
public override UnratedItem GetBlockUnratedType()
{
@@ -254,7 +243,7 @@ namespace MediaBrowser.Controller.Entities.Movies
return FlattenItems(boxset.GetLinkedChildren(), expandedFolders);
}
return new BaseItem[] { };
return Array.Empty<BaseItem>();
}
return new[] { item };

View File

@@ -6,8 +6,6 @@ using System.Collections.Generic;
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 @@ namespace MediaBrowser.Controller.Entities.Movies
public Guid[] LocalTrailerIds { get; set; }
public Guid[] RemoteTrailerIds { get; set; }
public MediaUrl[] RemoteTrailers { get; set; }
/// <summary>
/// Gets or sets the name of the TMDB collection.
/// </summary>
@@ -55,10 +51,7 @@ namespace MediaBrowser.Controller.Entities.Movies
return 0;
}
double value = 2;
value /= 3;
return value;
return 2 / 3;
}
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken)

View File

@@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities
public MusicVideo()
{
Artists = new string[] {};
Artists = Array.Empty<string>();
}
[IgnoreDataMember]

View File

@@ -58,6 +58,7 @@ namespace MediaBrowser.Controller.Entities
public override double GetDefaultPrimaryImageAspectRatio()
{
// REVIEW: @bond
if (Width.HasValue && Height.HasValue)
{
double width = Width.Value;
@@ -85,8 +86,8 @@ namespace MediaBrowser.Controller.Entities
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; }

View File

@@ -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 @@ namespace MediaBrowser.Controller.Entities.TV
public Episode()
{
RemoteTrailers = EmptyMediaUrlArray;
LocalTrailerIds = new Guid[] {};
RemoteTrailerIds = new Guid[] {};
LocalTrailerIds = Array.Empty<Guid>();
RemoteTrailerIds = Array.Empty<Guid>();
}
public Guid[] LocalTrailerIds { get; set; }
public Guid[] RemoteTrailerIds { get; set; }
public MediaUrl[] RemoteTrailers { get; set; }
/// <summary>
/// Gets the season in which it aired.
@@ -112,10 +111,7 @@ namespace MediaBrowser.Controller.Entities.TV
return 0;
}
double value = 16;
value /= 9;
return value;
return 16 / 9;
}
public override List<string> GetUserDataKeys()

View File

@@ -102,10 +102,11 @@ namespace MediaBrowser.Controller.Entities.TV
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 @@ namespace MediaBrowser.Controller.Entities.TV
public Guid FindSeriesId()
{
var series = FindParent<Series>();
return series == null ? Guid.Empty: series.Id;
return series == null ? Guid.Empty : series.Id;
}
/// <summary>

View File

@@ -23,9 +23,9 @@ namespace MediaBrowser.Controller.Entities.TV
public Series()
{
RemoteTrailers = EmptyMediaUrlArray;
LocalTrailerIds = new Guid[] {};
RemoteTrailerIds = new Guid[] {};
AirDays = new DayOfWeek[] { };
LocalTrailerIds = Array.Empty<Guid>();
RemoteTrailerIds = Array.Empty<Guid>();
AirDays = Array.Empty<DayOfWeek>();
}
public DayOfWeek[] AirDays { get; set; }
@@ -73,8 +73,6 @@ namespace MediaBrowser.Controller.Entities.TV
public Guid[] LocalTrailerIds { get; set; }
public Guid[] RemoteTrailerIds { get; set; }
public MediaUrl[] RemoteTrailers { get; set; }
/// <summary>
/// airdate, dvd or absolute
/// </summary>

View File

@@ -15,18 +15,13 @@ namespace MediaBrowser.Controller.Entities
{
public Trailer()
{
TrailerTypes = new TrailerType[] { };
TrailerTypes = Array.Empty<TrailerType>();
}
public TrailerType[] TrailerTypes { get; set; }
public override double GetDefaultPrimaryImageAspectRatio()
{
double value = 2;
value /= 3;
return value;
}
=> 2 / 3;
public override UnratedItem GetBlockUnratedType()
{

View File

@@ -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 @@ namespace MediaBrowser.Controller.Entities
}
}
//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 @@ namespace MediaBrowser.Controller.Entities
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 @@ namespace MediaBrowser.Controller.Entities
protected override Task ValidateChildrenInternal(IProgress<double> progress, System.Threading.CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService)
{
return Task.FromResult(true);
return Task.CompletedTask;
}
[IgnoreDataMember]

View File

@@ -10,7 +10,6 @@ using System.Globalization;
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 @@ namespace MediaBrowser.Controller.Entities
public bool HasSubtitles { get; set; }
public bool IsPlaceHolder { get; set; }
public bool IsShortcut { get; set; }
public string ShortcutPath { get; set; }
/// <summary>
/// Gets or sets the default index of the video stream.
@@ -173,7 +170,7 @@ namespace MediaBrowser.Controller.Entities
}
else
{
return new string[] {};
return Array.Empty<string>();
}
return mediaEncoder.GetPlayableStreamFileNames(Path, videoType);
}
@@ -186,9 +183,9 @@ namespace MediaBrowser.Controller.Entities
public Video()
{
AdditionalParts = new string[] {};
LocalAlternateVersions = new string[] {};
SubtitleFiles = new string[] {};
AdditionalParts = Array.Empty<string>();
LocalAlternateVersions = Array.Empty<string>();
SubtitleFiles = Array.Empty<string>();
LinkedAlternateVersions = EmptyLinkedChildArray;
}
@@ -215,10 +212,10 @@ namespace MediaBrowser.Controller.Entities
{
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 @@ namespace MediaBrowser.Controller.Entities
/// Gets the additional parts.
/// </summary>
/// <returns>IEnumerable{Video}.</returns>
public IEnumerable<Video> GetAdditionalParts()
public IOrderedEnumerable<Video> GetAdditionalParts()
{
return GetAdditionalPartIds()
.Select(i => LibraryManager.GetItemById(i))
@@ -420,8 +417,7 @@ namespace MediaBrowser.Controller.Entities
{
var updateType = base.UpdateFromResolvedItem(newItem);
var newVideo = newItem as Video;
if (newVideo != null)
if (newItem is Video newVideo)
{
if (!AdditionalParts.SequenceEqual(newVideo.AdditionalParts, StringComparer.Ordinal))
{
@@ -463,7 +459,7 @@ namespace MediaBrowser.Controller.Entities
.Select(i => i.FullName)
.ToArray();
}
return new string[] {};
return Array.Empty<string>();
}
/// <summary>
@@ -618,9 +614,5 @@ namespace MediaBrowser.Controller.Entities
return list;
}
public static bool IsHD (Video video) {
return video.Height >= 720;
}
}
}