mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 17:14:42 +01:00
Cleanup/simplification
* Removed useless copies/allocations * Reduced unneeded complexity
This commit is contained in:
@@ -36,10 +36,20 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo>
|
||||
{
|
||||
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>();
|
||||
private static readonly List<string> _supportedExtensions = new List<string>(SupportedImageExtensions)
|
||||
{
|
||||
".nfo",
|
||||
".xml",
|
||||
".srt",
|
||||
".vtt",
|
||||
".sub",
|
||||
".idx",
|
||||
".txt",
|
||||
".edl",
|
||||
".bif",
|
||||
".smi",
|
||||
".ttml"
|
||||
};
|
||||
|
||||
protected BaseItem()
|
||||
{
|
||||
@@ -49,8 +59,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
Genres = Array.Empty<string>();
|
||||
Studios = Array.Empty<string>();
|
||||
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
LockedFields = EmptyMetadataFieldsArray;
|
||||
ImageInfos = EmptyItemImageInfoArray;
|
||||
LockedFields = Array.Empty<MetadataFields>();
|
||||
ImageInfos = Array.Empty<ItemImageInfo>();
|
||||
ProductionLocations = Array.Empty<string>();
|
||||
RemoteTrailers = Array.Empty<MediaUrl>();
|
||||
ExtraIds = Array.Empty<Guid>();
|
||||
@@ -2452,10 +2462,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
|
||||
var filename = System.IO.Path.GetFileNameWithoutExtension(Path);
|
||||
var extensions = new List<string> { ".nfo", ".xml", ".srt", ".vtt", ".sub", ".idx", ".txt", ".edl", ".bif", ".smi", ".ttml" };
|
||||
extensions.AddRange(SupportedImageExtensions);
|
||||
|
||||
return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), extensions.ToArray(), false, false)
|
||||
return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), _supportedExtensions, false, false)
|
||||
.Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
public Folder()
|
||||
{
|
||||
LinkedChildren = EmptyLinkedChildArray;
|
||||
LinkedChildren = Array.Empty<LinkedChild>();
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
|
||||
@@ -25,22 +25,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
public DateTime DateModified { get; set; }
|
||||
|
||||
public int Width { get; set; }
|
||||
|
||||
public int Height { get; set; }
|
||||
|
||||
[IgnoreDataMember]
|
||||
public bool IsLocalFile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Path != null)
|
||||
{
|
||||
if (Path.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool IsLocalFile => Path == null || !Path.StartsWith("http", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
{
|
||||
public BoxSet()
|
||||
{
|
||||
RemoteTrailers = EmptyMediaUrlArray;
|
||||
RemoteTrailers = Array.Empty<MediaUrl>();
|
||||
LocalTrailerIds = Array.Empty<Guid>();
|
||||
RemoteTrailerIds = Array.Empty<Guid>();
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
|
||||
public Movie()
|
||||
{
|
||||
SpecialFeatureIds = new Guid[] { };
|
||||
RemoteTrailers = EmptyMediaUrlArray;
|
||||
LocalTrailerIds = new Guid[] { };
|
||||
RemoteTrailerIds = new Guid[] { };
|
||||
SpecialFeatureIds = Array.Empty<Guid>();
|
||||
RemoteTrailers = Array.Empty<MediaUrl>();
|
||||
LocalTrailerIds = Array.Empty<Guid>();
|
||||
RemoteTrailerIds = Array.Empty<Guid>();
|
||||
}
|
||||
|
||||
public Guid[] LocalTrailerIds { get; set; }
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
{
|
||||
public Episode()
|
||||
{
|
||||
RemoteTrailers = EmptyMediaUrlArray;
|
||||
RemoteTrailers = Array.Empty<MediaUrl>();
|
||||
LocalTrailerIds = Array.Empty<Guid>();
|
||||
RemoteTrailerIds = Array.Empty<Guid>();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
@@ -22,7 +21,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
{
|
||||
public Series()
|
||||
{
|
||||
RemoteTrailers = EmptyMediaUrlArray;
|
||||
RemoteTrailers = Array.Empty<MediaUrl>();
|
||||
LocalTrailerIds = Array.Empty<Guid>();
|
||||
RemoteTrailerIds = Array.Empty<Guid>();
|
||||
AirDays = Array.Empty<DayOfWeek>();
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
AdditionalParts = Array.Empty<string>();
|
||||
LocalAlternateVersions = Array.Empty<string>();
|
||||
SubtitleFiles = Array.Empty<string>();
|
||||
LinkedAlternateVersions = EmptyLinkedChildArray;
|
||||
LinkedAlternateVersions = Array.Empty<LinkedChild>();
|
||||
}
|
||||
|
||||
public override bool CanDownload()
|
||||
|
||||
Reference in New Issue
Block a user