< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.BaseItem
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/BaseItem.cs
Line coverage
51%
Covered lines: 376
Uncovered lines: 353
Coverable lines: 729
Total lines: 2675
Line coverage: 51.5%
Branch coverage
41%
Covered branches: 190
Total branches: 458
Branch coverage: 41.4%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor()100%11100%
get_SupportsAddingToPlaylist()100%210%
get_AlwaysScanInternalMetadataPath()100%11100%
get_SupportsPlayedStatus()100%210%
get_SupportsPositionTicksResume()100%210%
get_SupportsRemoteImageDownloading()100%11100%
get_Name()100%11100%
set_Name(...)100%11100%
get_IsUnaired()0%620%
get_IsThemeMedia()0%2040%
get_DisplayPreferencesId()50%22100%
get_SourceType()50%2266.66%
get_ContainingFolderPath()100%22100%
get_IsHidden()100%210%
get_LocationType()33.33%11650%
get_PathProtocol()100%22100%
get_IsFileProtocol()100%11100%
get_HasPathProtocol()100%210%
get_SupportsLocalMetadata()50%2266.66%
get_FileNameWithoutExtension()0%620%
get_EnableAlphaNumericSorting()100%11100%
get_IsHD()100%11100%
get_PrimaryImagePath()100%210%
get_MediaType()100%11100%
get_PhysicalLocations()0%620%
get_EnableMediaSourceDisplay()50%2266.66%
get_ForcedSortName()100%11100%
set_ForcedSortName(...)100%11100%
get_SortName()75%4480%
set_SortName(...)100%11100%
get_DisplayParentId()100%11100%
get_DisplayParent()100%22100%
get_HasLocalAlternateVersions()100%210%
get_OfficialRatingForComparison()75%4485.71%
get_CustomRatingForComparison()100%11100%
get_LatestItemsIndexContainer()100%210%
get_EnableRememberingTrackSelections()100%210%
get_IsTopParent()80%121075%
get_SupportsAncestors()100%11100%
get_SupportsOwnedItems()100%22100%
get_SupportsPeople()100%11100%
get_SupportsThemeMedia()100%210%
get_SupportsInheritedParentImages()100%210%
get_IsFolder()100%11100%
get_IsDisplayedAsFolder()100%210%
GetCustomRatingForComparision(...)87.5%8888.88%
GetDefaultPrimaryImageAspectRatio()100%210%
CreatePresentationUniqueKey()100%11100%
CanDelete()0%620%
IsAuthorizedToDelete(...)0%7280%
GetOwner()50%22100%
CanDelete(...)50%22100%
CanDelete(...)100%11100%
CanDownload()100%11100%
IsAuthorizedToDownload(...)100%210%
CanDownload(...)50%22100%
ToString()100%11100%
GetInternalMetadataPath()100%11100%
GetInternalMetadataPath(...)50%2275%
CreateSortName()71.42%171475%
ModifySortChunks(...)87.5%8893.75%
GetParent()100%22100%
FindParent()0%2040%
GetPlayAccess(...)50%2266.66%
GetMediaStreams()100%210%
IsActiveRecording()100%210%
GetMediaSources(...)0%7280%
GetAllItemsForMediaSources()100%210%
GetVersionInfo(...)0%1806420%
GetMediaSourceName(...)68.75%743265.51%
RefreshMetadata(...)100%11100%
IsVisibleStandaloneInternal(...)0%210140%
SetParent(...)100%22100%
GetFileSystemChildren(...)100%11100%
GetPresentationUniqueKey()0%620%
RequiresRefresh()66.66%7675%
GetUserDataKeys()50%5466.66%
UpdateFromResolvedItem(...)50%2260%
AfterMetadataRefresh()100%11100%
GetPreferredMetadataLanguage()100%88100%
GetPreferredMetadataCountryCode()100%88100%
IsSaveLocalMetadataEnabled()50%2275%
IsParentalAllowed(...)25%481650%
GetParentalRatingScore()75%4483.33%
GetInheritedTags()75%4485.71%
IsVisibleViaTags(...)38.88%591850%
GetBlockUnratedType()50%2266.66%
GetBlockUnratedValue(...)50%5466.66%
IsVisible(...)100%11100%
IsVisibleStandalone(...)0%2040%
GetClientTypeName()70%141066.66%
GetBaseItemKind()100%22100%
GetLinkedChild(...)0%7280%
FindLinkedChild(...)0%7280%
AddStudio(...)50%4475%
SetStudios(...)100%210%
AddGenre(...)100%22100%
MarkPlayed(...)0%110100%
MarkUnplayed(...)100%210%
ChangedExternally()100%210%
HasImage(...)100%11100%
SetImage(...)75%4490.9%
SetImagePath(...)75%4490.9%
RemoveImage(...)100%210%
RemoveImages(...)100%11100%
AddImage(...)100%11100%
ValidateImages()100%1212100%
GetImagePath(...)50%22100%
GetImageInfo(...)33.33%831221.05%
GetImageIndex(...)0%110100%
AddImages(...)85%202091.3%
GetImageInfo(...)100%11100%
GetDeletePaths()100%210%
GetLocalMetadataFilesToDelete()0%2040%
AllowsMultipleImages(...)100%22100%
SwapImagesAsync(...)0%110100%
IsPlayed(...)0%2040%
IsFavoriteOrLiked(...)0%4260%
IsUnplayed(...)0%2040%
MediaBrowser.Controller.Providers.IHasLookupInfo<MediaBrowser.Controller.Providers.ItemLookupInfo>.GetLookupInfo()100%11100%
GetItemLookupInfo()100%11100%
GetNameForMetadataLookup()100%11100%
BeforeMetadataRefresh(...)50%5466.66%
GetMappedPath(...)0%620%
FillUserDataDtoValues(...)0%4260%
GetEtag(...)100%11100%
GetEtagValues(...)100%11100%
GetAncestorIds()100%11100%
GetTopParent()100%22100%
GetIdsForAncestorQuery()100%11100%
GetRefreshProgress()100%210%
OnMetadataChanged()37.5%22840%
UpdateRatingToItems(...)0%4260%
GetThemeSongs(...)100%210%
GetThemeSongs(...)100%210%
GetThemeVideos(...)100%210%
GetThemeVideos(...)100%210%
GetExtras()100%11100%
GetExtras(...)100%210%
GetRunTimeTicksForPlayState()100%210%
Equals(...)0%620%
Equals(...)50%22100%
GetHashCode()100%11100%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/BaseItem.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591, SA1401
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Collections.Immutable;
 8using System.Globalization;
 9using System.IO;
 10using System.Linq;
 11using System.Text;
 12using System.Text.Json.Serialization;
 13using System.Threading;
 14using System.Threading.Tasks;
 15using Jellyfin.Data;
 16using Jellyfin.Data.Enums;
 17using Jellyfin.Database.Implementations.Entities;
 18using Jellyfin.Database.Implementations.Enums;
 19using Jellyfin.Extensions;
 20using MediaBrowser.Common.Extensions;
 21using MediaBrowser.Controller.Channels;
 22using MediaBrowser.Controller.Chapters;
 23using MediaBrowser.Controller.Configuration;
 24using MediaBrowser.Controller.Dto;
 25using MediaBrowser.Controller.Entities.Audio;
 26using MediaBrowser.Controller.Entities.TV;
 27using MediaBrowser.Controller.Library;
 28using MediaBrowser.Controller.MediaSegments;
 29using MediaBrowser.Controller.Persistence;
 30using MediaBrowser.Controller.Providers;
 31using MediaBrowser.Model.Dto;
 32using MediaBrowser.Model.Entities;
 33using MediaBrowser.Model.Globalization;
 34using MediaBrowser.Model.IO;
 35using MediaBrowser.Model.Library;
 36using MediaBrowser.Model.LiveTv;
 37using MediaBrowser.Model.MediaInfo;
 38using Microsoft.Extensions.Logging;
 39
 40namespace MediaBrowser.Controller.Entities
 41{
 42    /// <summary>
 43    /// Class BaseItem.
 44    /// </summary>
 45    public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo>, IEquatable<BaseItem>
 46    {
 47        private BaseItemKind? _baseItemKind;
 48
 49        public const string ThemeSongFileName = "theme";
 50
 51        /// <summary>
 52        /// The supported image extensions.
 53        /// </summary>
 454        public static readonly string[] SupportedImageExtensions
 455            = [".png", ".jpg", ".jpeg", ".webp", ".tbn", ".gif", ".svg"];
 56
 457        private static readonly List<string> _supportedExtensions = new List<string>(SupportedImageExtensions)
 458        {
 459            ".nfo",
 460            ".xml",
 461            ".srt",
 462            ".vtt",
 463            ".sub",
 464            ".sup",
 465            ".idx",
 466            ".txt",
 467            ".edl",
 468            ".bif",
 469            ".smi",
 470            ".ttml",
 471            ".lrc",
 472            ".elrc"
 473        };
 74
 75        /// <summary>
 76        /// Extra types that should be counted and displayed as "Special Features" in the UI.
 77        /// </summary>
 478        public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new HashSet<ExtraType>
 479        {
 480            Model.Entities.ExtraType.Unknown,
 481            Model.Entities.ExtraType.BehindTheScenes,
 482            Model.Entities.ExtraType.Clip,
 483            Model.Entities.ExtraType.DeletedScene,
 484            Model.Entities.ExtraType.Interview,
 485            Model.Entities.ExtraType.Sample,
 486            Model.Entities.ExtraType.Scene,
 487            Model.Entities.ExtraType.Featurette,
 488            Model.Entities.ExtraType.Short
 489        };
 90
 91        private string _sortName;
 92
 93        private string _forcedSortName;
 94
 95        private string _name;
 96
 97        public const char SlugChar = '-';
 98
 99        protected BaseItem()
 100        {
 978101            Tags = Array.Empty<string>();
 978102            Genres = Array.Empty<string>();
 978103            Studios = Array.Empty<string>();
 978104            ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 978105            LockedFields = Array.Empty<MetadataField>();
 978106            ImageInfos = Array.Empty<ItemImageInfo>();
 978107            ProductionLocations = Array.Empty<string>();
 978108            RemoteTrailers = Array.Empty<MediaUrl>();
 978109            ExtraIds = Array.Empty<Guid>();
 978110        }
 111
 112        [JsonIgnore]
 113        public string PreferredMetadataCountryCode { get; set; }
 114
 115        [JsonIgnore]
 116        public string PreferredMetadataLanguage { get; set; }
 117
 118        public long? Size { get; set; }
 119
 120        public string Container { get; set; }
 121
 122        [JsonIgnore]
 123        public string Tagline { get; set; }
 124
 125        [JsonIgnore]
 126        public virtual ItemImageInfo[] ImageInfos { get; set; }
 127
 128        [JsonIgnore]
 129        public bool IsVirtualItem { get; set; }
 130
 131        /// <summary>
 132        /// Gets or sets the album.
 133        /// </summary>
 134        /// <value>The album.</value>
 135        [JsonIgnore]
 136        public string Album { get; set; }
 137
 138        /// <summary>
 139        /// Gets or sets the LUFS value.
 140        /// </summary>
 141        /// <value>The LUFS Value.</value>
 142        [JsonIgnore]
 143        public float? LUFS { get; set; }
 144
 145        /// <summary>
 146        /// Gets or sets the gain required for audio normalization.
 147        /// </summary>
 148        /// <value>The gain required for audio normalization.</value>
 149        [JsonIgnore]
 150        public float? NormalizationGain { get; set; }
 151
 152        /// <summary>
 153        /// Gets or sets the channel identifier.
 154        /// </summary>
 155        /// <value>The channel identifier.</value>
 156        [JsonIgnore]
 157        public Guid ChannelId { get; set; }
 158
 159        [JsonIgnore]
 0160        public virtual bool SupportsAddingToPlaylist => false;
 161
 162        [JsonIgnore]
 13163        public virtual bool AlwaysScanInternalMetadataPath => false;
 164
 165        /// <summary>
 166        /// Gets or sets a value indicating whether this instance is in mixed folder.
 167        /// </summary>
 168        /// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
 169        [JsonIgnore]
 170        public bool IsInMixedFolder { get; set; }
 171
 172        [JsonIgnore]
 0173        public virtual bool SupportsPlayedStatus => false;
 174
 175        [JsonIgnore]
 0176        public virtual bool SupportsPositionTicksResume => false;
 177
 178        [JsonIgnore]
 17179        public virtual bool SupportsRemoteImageDownloading => true;
 180
 181        /// <summary>
 182        /// Gets or sets the name.
 183        /// </summary>
 184        /// <value>The name.</value>
 185        [JsonIgnore]
 186        public virtual string Name
 187        {
 973188            get => _name;
 189            set
 190            {
 367191                _name = value;
 192
 193                // lazy load this again
 367194                _sortName = null;
 367195            }
 196        }
 197
 198        [JsonIgnore]
 0199        public bool IsUnaired => PremiereDate.HasValue && PremiereDate.Value.ToLocalTime().Date >= DateTime.Now.Date;
 200
 201        [JsonIgnore]
 202        public int? TotalBitrate { get; set; }
 203
 204        [JsonIgnore]
 205        public ExtraType? ExtraType { get; set; }
 206
 207        [JsonIgnore]
 0208        public bool IsThemeMedia => ExtraType.HasValue && (ExtraType.Value == Model.Entities.ExtraType.ThemeSong || Extr
 209
 210        [JsonIgnore]
 211        public string OriginalTitle { get; set; }
 212
 213        /// <summary>
 214        /// Gets or sets the id.
 215        /// </summary>
 216        /// <value>The id.</value>
 217        [JsonIgnore]
 218        public Guid Id { get; set; }
 219
 220        [JsonIgnore]
 221        public Guid OwnerId { get; set; }
 222
 223        /// <summary>
 224        /// Gets or sets the audio.
 225        /// </summary>
 226        /// <value>The audio.</value>
 227        [JsonIgnore]
 228        public ProgramAudio? Audio { get; set; }
 229
 230        /// <summary>
 231        /// Gets the id that should be used to key display prefs for this item.
 232        /// Default is based on the type for everything except actual generic folders.
 233        /// </summary>
 234        /// <value>The display prefs id.</value>
 235        [JsonIgnore]
 236        public virtual Guid DisplayPreferencesId
 237        {
 238            get
 239            {
 6240                var thisType = GetType();
 6241                return thisType == typeof(Folder) ? Id : thisType.FullName.GetMD5();
 242            }
 243        }
 244
 245        /// <summary>
 246        /// Gets or sets the path.
 247        /// </summary>
 248        /// <value>The path.</value>
 249        [JsonIgnore]
 250        public virtual string Path { get; set; }
 251
 252        [JsonIgnore]
 253        public virtual SourceType SourceType
 254        {
 255            get
 256            {
 1951257                if (!ChannelId.IsEmpty())
 258                {
 0259                    return SourceType.Channel;
 260                }
 261
 1951262                return SourceType.Library;
 263            }
 264        }
 265
 266        /// <summary>
 267        /// Gets the folder containing the item.
 268        /// If the item is a folder, it returns the folder itself.
 269        /// </summary>
 270        [JsonIgnore]
 271        public virtual string ContainingFolderPath
 272        {
 273            get
 274            {
 382275                if (IsFolder)
 276                {
 331277                    return Path;
 278                }
 279
 51280                return System.IO.Path.GetDirectoryName(Path);
 281            }
 282        }
 283
 284        /// <summary>
 285        /// Gets or sets the name of the service.
 286        /// </summary>
 287        /// <value>The name of the service.</value>
 288        [JsonIgnore]
 289        public string ServiceName { get; set; }
 290
 291        /// <summary>
 292        /// Gets or sets the external id.
 293        /// </summary>
 294        /// <remarks>
 295        /// If this content came from an external service, the id of the content on that service.
 296        /// </remarks>
 297        [JsonIgnore]
 298        public string ExternalId { get; set; }
 299
 300        [JsonIgnore]
 301        public string ExternalSeriesId { get; set; }
 302
 303        [JsonIgnore]
 0304        public virtual bool IsHidden => false;
 305
 306        /// <summary>
 307        /// Gets the type of the location.
 308        /// </summary>
 309        /// <value>The type of the location.</value>
 310        [JsonIgnore]
 311        public virtual LocationType LocationType
 312        {
 313            get
 314            {
 9315                var path = Path;
 9316                if (string.IsNullOrEmpty(path))
 317                {
 0318                    if (SourceType == SourceType.Channel)
 319                    {
 0320                        return LocationType.Remote;
 321                    }
 322
 0323                    return LocationType.Virtual;
 324                }
 325
 9326                return FileSystem.IsPathFile(path) ? LocationType.FileSystem : LocationType.Remote;
 327            }
 328        }
 329
 330        [JsonIgnore]
 331        public MediaProtocol? PathProtocol
 332        {
 333            get
 334            {
 2457335                var path = Path;
 336
 2457337                if (string.IsNullOrEmpty(path))
 338                {
 116339                    return null;
 340                }
 341
 2341342                return MediaSourceManager.GetPathProtocol(path);
 343            }
 344        }
 345
 346        [JsonIgnore]
 2436347        public bool IsFileProtocol => PathProtocol == MediaProtocol.File;
 348
 349        [JsonIgnore]
 0350        public bool HasPathProtocol => PathProtocol.HasValue;
 351
 352        [JsonIgnore]
 353        public virtual bool SupportsLocalMetadata
 354        {
 355            get
 356            {
 1310357                if (SourceType == SourceType.Channel)
 358                {
 0359                    return false;
 360                }
 361
 1310362                return IsFileProtocol;
 363            }
 364        }
 365
 366        [JsonIgnore]
 367        public virtual string FileNameWithoutExtension
 368        {
 369            get
 370            {
 0371                if (IsFileProtocol)
 372                {
 0373                    return System.IO.Path.GetFileNameWithoutExtension(Path);
 374                }
 375
 0376                return null;
 377            }
 378        }
 379
 380        [JsonIgnore]
 105381        public virtual bool EnableAlphaNumericSorting => true;
 382
 112383        public virtual bool IsHD => Height >= 720;
 384
 385        public bool IsShortcut { get; set; }
 386
 387        public string ShortcutPath { get; set; }
 388
 389        public int Width { get; set; }
 390
 391        public int Height { get; set; }
 392
 393        public Guid[] ExtraIds { get; set; }
 394
 395        /// <summary>
 396        /// Gets the primary image path.
 397        /// </summary>
 398        /// <remarks>
 399        /// This is just a helper for convenience.
 400        /// </remarks>
 401        /// <value>The primary image path.</value>
 402        [JsonIgnore]
 0403        public string PrimaryImagePath => this.GetImagePath(ImageType.Primary);
 404
 405        /// <summary>
 406        /// Gets or sets the date created.
 407        /// </summary>
 408        /// <value>The date created.</value>
 409        [JsonIgnore]
 410        public DateTime DateCreated { get; set; }
 411
 412        /// <summary>
 413        /// Gets or sets the date modified.
 414        /// </summary>
 415        /// <value>The date modified.</value>
 416        [JsonIgnore]
 417        public DateTime DateModified { get; set; }
 418
 419        public DateTime DateLastSaved { get; set; }
 420
 421        [JsonIgnore]
 422        public DateTime DateLastRefreshed { get; set; }
 423
 424        [JsonIgnore]
 425        public bool IsLocked { get; set; }
 426
 427        /// <summary>
 428        /// Gets or sets the locked fields.
 429        /// </summary>
 430        /// <value>The locked fields.</value>
 431        [JsonIgnore]
 432        public MetadataField[] LockedFields { get; set; }
 433
 434        /// <summary>
 435        /// Gets the type of the media.
 436        /// </summary>
 437        /// <value>The type of the media.</value>
 438        [JsonIgnore]
 102439        public virtual MediaType MediaType => MediaType.Unknown;
 440
 441        [JsonIgnore]
 442        public virtual string[] PhysicalLocations
 443        {
 444            get
 445            {
 0446                if (!IsFileProtocol)
 447                {
 0448                    return Array.Empty<string>();
 449                }
 450
 0451                return [Path];
 452            }
 453        }
 454
 455        [JsonIgnore]
 456        public bool EnableMediaSourceDisplay
 457        {
 458            get
 459            {
 6460                if (SourceType == SourceType.Channel)
 461                {
 0462                    return ChannelManager.EnableMediaSourceDisplay(this);
 463                }
 464
 6465                return true;
 466            }
 467        }
 468
 469        [JsonIgnore]
 470        public Guid ParentId { get; set; }
 471
 472        /// <summary>
 473        /// Gets or sets the logger.
 474        /// </summary>
 475        public static ILogger<BaseItem> Logger { get; set; }
 476
 477        public static ILibraryManager LibraryManager { get; set; }
 478
 479        public static IServerConfigurationManager ConfigurationManager { get; set; }
 480
 481        public static IProviderManager ProviderManager { get; set; }
 482
 483        public static ILocalizationManager LocalizationManager { get; set; }
 484
 485        public static IItemRepository ItemRepository { get; set; }
 486
 487        public static IChapterManager ChapterManager { get; set; }
 488
 489        public static IFileSystem FileSystem { get; set; }
 490
 491        public static IUserDataManager UserDataManager { get; set; }
 492
 493        public static IChannelManager ChannelManager { get; set; }
 494
 495        public static IMediaSourceManager MediaSourceManager { get; set; }
 496
 497        public static IMediaSegmentManager MediaSegmentManager { get; set; }
 498
 499        /// <summary>
 500        /// Gets or sets the name of the forced sort.
 501        /// </summary>
 502        /// <value>The name of the forced sort.</value>
 503        [JsonIgnore]
 504        public string ForcedSortName
 505        {
 449506            get => _forcedSortName;
 507            set
 508            {
 106509                _forcedSortName = value;
 106510                _sortName = null;
 106511            }
 512        }
 513
 514        /// <summary>
 515        /// Gets or sets the name of the sort.
 516        /// </summary>
 517        /// <value>The name of the sort.</value>
 518        [JsonIgnore]
 519        public string SortName
 520        {
 521            get
 522            {
 142523                if (_sortName is null)
 524                {
 105525                    if (!string.IsNullOrEmpty(ForcedSortName))
 526                    {
 527                        // Need the ToLower because that's what CreateSortName does
 0528                        _sortName = ModifySortChunks(ForcedSortName).ToLowerInvariant();
 529                    }
 530                    else
 531                    {
 105532                        _sortName = CreateSortName();
 533                    }
 534                }
 535
 142536                return _sortName;
 537            }
 538
 135539            set => _sortName = value;
 540        }
 541
 542        [JsonIgnore]
 326543        public virtual Guid DisplayParentId => ParentId;
 544
 545        [JsonIgnore]
 546        public BaseItem DisplayParent
 547        {
 548            get
 549            {
 320550                var id = DisplayParentId;
 320551                if (id.IsEmpty())
 552                {
 242553                    return null;
 554                }
 555
 78556                return LibraryManager.GetItemById(id);
 557            }
 558        }
 559
 560        /// <summary>
 561        /// Gets or sets the date that the item first debuted. For movies this could be premiere date, episodes would be
 562        /// </summary>
 563        /// <value>The premiere date.</value>
 564        [JsonIgnore]
 565        public DateTime? PremiereDate { get; set; }
 566
 567        /// <summary>
 568        /// Gets or sets the end date.
 569        /// </summary>
 570        /// <value>The end date.</value>
 571        [JsonIgnore]
 572        public DateTime? EndDate { get; set; }
 573
 574        /// <summary>
 575        /// Gets or sets the official rating.
 576        /// </summary>
 577        /// <value>The official rating.</value>
 578        [JsonIgnore]
 579        public string OfficialRating { get; set; }
 580
 581        [JsonIgnore]
 582        public int? InheritedParentalRatingValue { get; set; }
 583
 584        [JsonIgnore]
 585        public int? InheritedParentalRatingSubValue { get; set; }
 586
 587        /// <summary>
 588        /// Gets or sets the critic rating.
 589        /// </summary>
 590        /// <value>The critic rating.</value>
 591        [JsonIgnore]
 592        public float? CriticRating { get; set; }
 593
 594        /// <summary>
 595        /// Gets or sets the custom rating.
 596        /// </summary>
 597        /// <value>The custom rating.</value>
 598        [JsonIgnore]
 599        public string CustomRating { get; set; }
 600
 601        /// <summary>
 602        /// Gets or sets the overview.
 603        /// </summary>
 604        /// <value>The overview.</value>
 605        [JsonIgnore]
 606        public string Overview { get; set; }
 607
 608        /// <summary>
 609        /// Gets or sets the studios.
 610        /// </summary>
 611        /// <value>The studios.</value>
 612        [JsonIgnore]
 613        public string[] Studios { get; set; }
 614
 615        /// <summary>
 616        /// Gets or sets the genres.
 617        /// </summary>
 618        /// <value>The genres.</value>
 619        [JsonIgnore]
 620        public string[] Genres { get; set; }
 621
 622        /// <summary>
 623        /// Gets or sets the tags.
 624        /// </summary>
 625        /// <value>The tags.</value>
 626        [JsonIgnore]
 627        public string[] Tags { get; set; }
 628
 629        [JsonIgnore]
 630        public string[] ProductionLocations { get; set; }
 631
 632        /// <summary>
 633        /// Gets or sets the home page URL.
 634        /// </summary>
 635        /// <value>The home page URL.</value>
 636        [JsonIgnore]
 637        public string HomePageUrl { get; set; }
 638
 639        /// <summary>
 640        /// Gets or sets the community rating.
 641        /// </summary>
 642        /// <value>The community rating.</value>
 643        [JsonIgnore]
 644        public float? CommunityRating { get; set; }
 645
 646        /// <summary>
 647        /// Gets or sets the run time ticks.
 648        /// </summary>
 649        /// <value>The run time ticks.</value>
 650        [JsonIgnore]
 651        public long? RunTimeTicks { get; set; }
 652
 653        /// <summary>
 654        /// Gets or sets the production year.
 655        /// </summary>
 656        /// <value>The production year.</value>
 657        [JsonIgnore]
 658        public int? ProductionYear { get; set; }
 659
 660        /// <summary>
 661        /// Gets or sets the index number. If the item is part of a series, this is it's number in the series.
 662        /// This could be episode number, album track number, etc.
 663        /// </summary>
 664        /// <value>The index number.</value>
 665        [JsonIgnore]
 666        public int? IndexNumber { get; set; }
 667
 668        /// <summary>
 669        /// Gets or sets the parent index number. For an episode this could be the season number, or for a song this cou
 670        /// </summary>
 671        /// <value>The parent index number.</value>
 672        [JsonIgnore]
 673        public int? ParentIndexNumber { get; set; }
 674
 675        [JsonIgnore]
 0676        public virtual bool HasLocalAlternateVersions => false;
 677
 678        [JsonIgnore]
 679        public string OfficialRatingForComparison
 680        {
 681            get
 682            {
 160683                var officialRating = OfficialRating;
 160684                if (!string.IsNullOrEmpty(officialRating))
 685                {
 0686                    return officialRating;
 687                }
 688
 160689                var parent = DisplayParent;
 160690                if (parent is not null)
 691                {
 39692                    return parent.OfficialRatingForComparison;
 693                }
 694
 121695                return null;
 696            }
 697        }
 698
 699        [JsonIgnore]
 700        public string CustomRatingForComparison
 701        {
 702            get
 703            {
 121704                return GetCustomRatingForComparision();
 705            }
 706        }
 707
 708        /// <summary>
 709        /// Gets or sets the provider ids.
 710        /// </summary>
 711        /// <value>The provider ids.</value>
 712        [JsonIgnore]
 713        public Dictionary<string, string> ProviderIds { get; set; }
 714
 715        [JsonIgnore]
 0716        public virtual Folder LatestItemsIndexContainer => null;
 717
 718        [JsonIgnore]
 719        public string PresentationUniqueKey { get; set; }
 720
 721        [JsonIgnore]
 0722        public virtual bool EnableRememberingTrackSelections => true;
 723
 724        [JsonIgnore]
 725        public virtual bool IsTopParent
 726        {
 727            get
 728            {
 244729                if (this is BasePluginFolder || this is Channel)
 730                {
 53731                    return true;
 732                }
 733
 191734                if (this is IHasCollectionType view)
 735                {
 17736                    if (view.CollectionType == CollectionType.livetv)
 737                    {
 0738                        return true;
 739                    }
 740                }
 741
 191742                if (GetParent() is AggregateFolder)
 743                {
 0744                    return true;
 745                }
 746
 191747                return false;
 748            }
 749        }
 750
 751        [JsonIgnore]
 186752        public virtual bool SupportsAncestors => true;
 753
 754        [JsonIgnore]
 88755        protected virtual bool SupportsOwnedItems => !ParentId.IsEmpty() && IsFileProtocol;
 756
 757        [JsonIgnore]
 68758        public virtual bool SupportsPeople => false;
 759
 760        [JsonIgnore]
 0761        public virtual bool SupportsThemeMedia => false;
 762
 763        [JsonIgnore]
 0764        public virtual bool SupportsInheritedParentImages => false;
 765
 766        /// <summary>
 767        /// Gets a value indicating whether this instance is folder.
 768        /// </summary>
 769        /// <value><c>true</c> if this instance is folder; otherwise, <c>false</c>.</value>
 770        [JsonIgnore]
 71771        public virtual bool IsFolder => false;
 772
 773        [JsonIgnore]
 0774        public virtual bool IsDisplayedAsFolder => false;
 775
 776        /// <summary>
 777        /// Gets or sets the remote trailers.
 778        /// </summary>
 779        /// <value>The remote trailers.</value>
 780        public IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
 781
 782        private string GetCustomRatingForComparision(HashSet<Guid> callstack = null)
 783        {
 160784            callstack ??= new();
 160785            var customRating = CustomRating;
 160786            if (!string.IsNullOrEmpty(customRating))
 787            {
 0788                return customRating;
 789            }
 790
 160791            callstack.Add(Id);
 792
 160793            var parent = DisplayParent;
 160794            if (parent is not null && !callstack.Contains(parent.Id))
 795            {
 39796                return parent.GetCustomRatingForComparision(callstack);
 797            }
 798
 121799            return null;
 800        }
 801
 802        public virtual double GetDefaultPrimaryImageAspectRatio()
 803        {
 0804            return 0;
 805        }
 806
 807        public virtual string CreatePresentationUniqueKey()
 808        {
 54809            return Id.ToString("N", CultureInfo.InvariantCulture);
 810        }
 811
 812        public virtual bool CanDelete()
 813        {
 0814            if (SourceType == SourceType.Channel)
 815            {
 0816                return ChannelManager.CanDelete(this);
 817            }
 818
 0819            return IsFileProtocol;
 820        }
 821
 822        public virtual bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
 823        {
 0824            if (user.HasPermission(PermissionKind.EnableContentDeletion))
 825            {
 0826                return true;
 827            }
 828
 0829            var allowed = user.GetPreferenceValues<Guid>(PreferenceKind.EnableContentDeletionFromFolders);
 830
 0831            if (SourceType == SourceType.Channel)
 832            {
 0833                return allowed.Contains(ChannelId);
 834            }
 835
 0836            var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
 837
 0838            foreach (var folder in collectionFolders)
 839            {
 0840                if (allowed.Contains(folder.Id))
 841                {
 0842                    return true;
 843                }
 844            }
 845
 0846            return false;
 0847        }
 848
 849        public BaseItem GetOwner()
 850        {
 673851            var ownerId = OwnerId;
 673852            return ownerId.IsEmpty() ? null : LibraryManager.GetItemById(ownerId);
 853        }
 854
 855        public bool CanDelete(User user, List<Folder> allCollectionFolders)
 856        {
 6857            return CanDelete() && IsAuthorizedToDelete(user, allCollectionFolders);
 858        }
 859
 860        public virtual bool CanDelete(User user)
 861        {
 6862            var allCollectionFolders = LibraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
 863
 6864            return CanDelete(user, allCollectionFolders);
 865        }
 866
 867        public virtual bool CanDownload()
 868        {
 6869            return false;
 870        }
 871
 872        public virtual bool IsAuthorizedToDownload(User user)
 873        {
 0874            return user.HasPermission(PermissionKind.EnableContentDownloading);
 875        }
 876
 877        public bool CanDownload(User user)
 878        {
 6879            return CanDownload() && IsAuthorizedToDownload(user);
 880        }
 881
 882        /// <inheritdoc />
 883        public override string ToString()
 884        {
 69885            return Name;
 886        }
 887
 888        public virtual string GetInternalMetadataPath()
 889        {
 70890            var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath;
 891
 70892            return GetInternalMetadataPath(basePath);
 893        }
 894
 895        protected virtual string GetInternalMetadataPath(string basePath)
 896        {
 70897            if (SourceType == SourceType.Channel)
 898            {
 0899                return System.IO.Path.Join(basePath, "channels", ChannelId.ToString("N", CultureInfo.InvariantCulture), 
 900            }
 901
 70902            ReadOnlySpan<char> idString = Id.ToString("N", CultureInfo.InvariantCulture);
 903
 70904            return System.IO.Path.Join(basePath, "library", idString[..2], idString);
 905        }
 906
 907        /// <summary>
 908        /// Creates the name of the sort.
 909        /// </summary>
 910        /// <returns>System.String.</returns>
 911        protected virtual string CreateSortName()
 912        {
 105913            if (Name is null)
 914            {
 0915                return null; // some items may not have name filled in properly
 916            }
 917
 105918            if (!EnableAlphaNumericSorting)
 919            {
 0920                return Name.TrimStart();
 921            }
 922
 105923            var sortable = Name.Trim().ToLowerInvariant();
 924
 840925            foreach (var search in ConfigurationManager.Configuration.SortRemoveWords)
 926            {
 927                // Remove from beginning if a space follows
 315928                if (sortable.StartsWith(search + " ", StringComparison.Ordinal))
 929                {
 0930                    sortable = sortable.Remove(0, search.Length + 1);
 931                }
 932
 933                // Remove from middle if surrounded by spaces
 315934                sortable = sortable.Replace(" " + search + " ", " ", StringComparison.Ordinal);
 935
 936                // Remove from end if preceeded by a space
 315937                if (sortable.EndsWith(" " + search, StringComparison.Ordinal))
 938                {
 0939                    sortable = sortable.Remove(sortable.Length - (search.Length + 1));
 940                }
 941            }
 942
 1470943            foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters)
 944            {
 630945                sortable = sortable.Replace(removeChar, string.Empty, StringComparison.Ordinal);
 946            }
 947
 840948            foreach (var replaceChar in ConfigurationManager.Configuration.SortReplaceCharacters)
 949            {
 315950                sortable = sortable.Replace(replaceChar, " ", StringComparison.Ordinal);
 951            }
 952
 105953            return ModifySortChunks(sortable);
 954        }
 955
 956        internal static string ModifySortChunks(ReadOnlySpan<char> name)
 957        {
 958            static void AppendChunk(StringBuilder builder, bool isDigitChunk, ReadOnlySpan<char> chunk)
 959            {
 960                if (isDigitChunk && chunk.Length < 10)
 961                {
 962                    builder.Append('0', 10 - chunk.Length);
 963                }
 964
 965                builder.Append(chunk);
 966            }
 967
 111968            if (name.IsEmpty)
 969            {
 1970                return string.Empty;
 971            }
 972
 110973            var builder = new StringBuilder(name.Length);
 974
 110975            int chunkStart = 0;
 110976            bool isDigitChunk = char.IsDigit(name[0]);
 1732977            for (int i = 0; i < name.Length; i++)
 978            {
 756979                var isDigit = char.IsDigit(name[i]);
 756980                if (isDigit != isDigitChunk)
 981                {
 9982                    AppendChunk(builder, isDigitChunk, name.Slice(chunkStart, i - chunkStart));
 9983                    chunkStart = i;
 9984                    isDigitChunk = isDigit;
 985                }
 986            }
 987
 110988            AppendChunk(builder, isDigitChunk, name.Slice(chunkStart));
 989
 990            // logger.LogDebug("ModifySortChunks Start: {0} End: {1}", name, builder.ToString());
 110991            var result = builder.ToString().RemoveDiacritics();
 110992            if (!result.All(char.IsAscii))
 993            {
 0994                result = result.Transliterated();
 995            }
 996
 110997            return result;
 998        }
 999
 1000        public BaseItem GetParent()
 1001        {
 16621002            var parentId = ParentId;
 16621003            if (parentId.IsEmpty())
 1004            {
 13231005                return null;
 1006            }
 1007
 3391008            return LibraryManager.GetItemById(parentId);
 1009        }
 1010
 1011        public IEnumerable<BaseItem> GetParents()
 1012        {
 1013            var parent = GetParent();
 1014
 1015            while (parent is not null)
 1016            {
 1017                yield return parent;
 1018
 1019                parent = parent.GetParent();
 1020            }
 1021        }
 1022
 1023        /// <summary>
 1024        /// Finds a parent of a given type.
 1025        /// </summary>
 1026        /// <typeparam name="T">Type of parent.</typeparam>
 1027        /// <returns>``0.</returns>
 1028        public T FindParent<T>()
 1029            where T : Folder
 1030        {
 01031            foreach (var parent in GetParents())
 1032            {
 01033                if (parent is T item)
 1034                {
 01035                    return item;
 1036                }
 1037            }
 1038
 01039            return null;
 01040        }
 1041
 1042        /// <summary>
 1043        /// Gets the play access.
 1044        /// </summary>
 1045        /// <param name="user">The user.</param>
 1046        /// <returns>PlayAccess.</returns>
 1047        public PlayAccess GetPlayAccess(User user)
 1048        {
 61049            if (!user.HasPermission(PermissionKind.EnableMediaPlayback))
 1050            {
 01051                return PlayAccess.None;
 1052            }
 1053
 1054            // if (!user.IsParentalScheduleAllowed())
 1055            // {
 1056            //    return PlayAccess.None;
 1057            // }
 1058
 61059            return PlayAccess.Full;
 1060        }
 1061
 1062        public virtual IReadOnlyList<MediaStream> GetMediaStreams()
 1063        {
 01064            return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
 01065            {
 01066                ItemId = Id
 01067            });
 1068        }
 1069
 1070        protected virtual bool IsActiveRecording()
 1071        {
 01072            return false;
 1073        }
 1074
 1075        public virtual IReadOnlyList<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
 1076        {
 01077            if (SourceType == SourceType.Channel)
 1078            {
 01079                var sources = ChannelManager.GetStaticMediaSources(this, CancellationToken.None)
 01080                           .ToList();
 1081
 01082                if (sources.Count > 0)
 1083                {
 01084                    return sources;
 1085                }
 1086            }
 1087
 01088            var list = GetAllItemsForMediaSources();
 01089            var result = list.Select(i => GetVersionInfo(enablePathSubstitution, i.Item, i.MediaSourceType)).ToList();
 1090
 01091            if (IsActiveRecording())
 1092            {
 01093                foreach (var mediaSource in result)
 1094                {
 01095                    mediaSource.Type = MediaSourceType.Placeholder;
 1096                }
 1097            }
 1098
 01099            return result.OrderBy(i =>
 01100            {
 01101                if (i.VideoType == VideoType.VideoFile)
 01102                {
 01103                    return 0;
 01104                }
 01105
 01106                return 1;
 01107            }).ThenBy(i => i.Video3DFormat.HasValue ? 1 : 0)
 01108            .ThenByDescending(i => i, new MediaSourceWidthComparator())
 01109            .ToArray();
 1110        }
 1111
 1112        protected virtual IEnumerable<(BaseItem Item, MediaSourceType MediaSourceType)> GetAllItemsForMediaSources()
 1113        {
 01114            return Enumerable.Empty<(BaseItem, MediaSourceType)>();
 1115        }
 1116
 1117        private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type)
 1118        {
 01119            ArgumentNullException.ThrowIfNull(item);
 1120
 01121            var protocol = item.PathProtocol;
 1122
 01123            var info = new MediaSourceInfo
 01124            {
 01125                Id = item.Id.ToString("N", CultureInfo.InvariantCulture),
 01126                Protocol = protocol ?? MediaProtocol.File,
 01127                MediaStreams = MediaSourceManager.GetMediaStreams(item.Id),
 01128                MediaAttachments = MediaSourceManager.GetMediaAttachments(item.Id),
 01129                Name = GetMediaSourceName(item),
 01130                Path = enablePathSubstitution ? GetMappedPath(item, item.Path, protocol) : item.Path,
 01131                RunTimeTicks = item.RunTimeTicks,
 01132                Container = item.Container,
 01133                Size = item.Size,
 01134                Type = type,
 01135                HasSegments = MediaSegmentManager.IsTypeSupported(item)
 01136                    && (protocol is null or MediaProtocol.File)
 01137                    && MediaSegmentManager.HasSegments(item.Id)
 01138            };
 1139
 01140            if (string.IsNullOrEmpty(info.Path))
 1141            {
 01142                info.Type = MediaSourceType.Placeholder;
 1143            }
 1144
 01145            if (info.Protocol == MediaProtocol.File)
 1146            {
 01147                info.ETag = item.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N", Cultur
 1148            }
 1149
 01150            var video = item as Video;
 01151            if (video is not null)
 1152            {
 01153                info.IsoType = video.IsoType;
 01154                info.VideoType = video.VideoType;
 01155                info.Video3DFormat = video.Video3DFormat;
 01156                info.Timestamp = video.Timestamp;
 1157
 01158                if (video.IsShortcut)
 1159                {
 01160                    info.IsRemote = true;
 01161                    info.Path = video.ShortcutPath;
 01162                    info.Protocol = MediaSourceManager.GetPathProtocol(info.Path);
 1163                }
 1164
 01165                if (string.IsNullOrEmpty(info.Container))
 1166                {
 01167                    if (video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Iso)
 1168                    {
 01169                        if (protocol.HasValue && protocol.Value == MediaProtocol.File)
 1170                        {
 01171                            info.Container = System.IO.Path.GetExtension(item.Path).TrimStart('.');
 1172                        }
 1173                    }
 1174                }
 1175            }
 1176
 01177            if (string.IsNullOrEmpty(info.Container))
 1178            {
 01179                if (protocol.HasValue && protocol.Value == MediaProtocol.File)
 1180                {
 01181                    info.Container = System.IO.Path.GetExtension(item.Path).TrimStart('.');
 1182                }
 1183            }
 1184
 01185            if (info.SupportsDirectStream && !string.IsNullOrEmpty(info.Path))
 1186            {
 01187                info.SupportsDirectStream = MediaSourceManager.SupportsDirectStream(info.Path, info.Protocol);
 1188            }
 1189
 01190            if (video is not null && video.VideoType != VideoType.VideoFile)
 1191            {
 01192                info.SupportsDirectStream = false;
 1193            }
 1194
 01195            info.Bitrate = item.TotalBitrate;
 01196            info.InferTotalBitrate();
 1197
 01198            return info;
 1199        }
 1200
 1201        internal string GetMediaSourceName(BaseItem item)
 1202        {
 41203            var terms = new List<string>();
 1204
 41205            var path = item.Path;
 41206            if (item.IsFileProtocol && !string.IsNullOrEmpty(path))
 1207            {
 41208                var displayName = System.IO.Path.GetFileNameWithoutExtension(path);
 41209                if (HasLocalAlternateVersions)
 1210                {
 41211                    var containingFolderName = System.IO.Path.GetFileName(ContainingFolderPath);
 41212                    if (displayName.Length > containingFolderName.Length && displayName.StartsWith(containingFolderName,
 1213                    {
 21214                        var name = displayName.AsSpan(containingFolderName.Length).TrimStart([' ', '-']);
 21215                        if (!name.IsWhiteSpace())
 1216                        {
 21217                            terms.Add(name.ToString());
 1218                        }
 1219                    }
 1220                }
 1221
 41222                if (terms.Count == 0)
 1223                {
 21224                    terms.Add(displayName);
 1225                }
 1226            }
 1227
 41228            if (terms.Count == 0)
 1229            {
 01230                terms.Add(item.Name);
 1231            }
 1232
 41233            if (item is Video video)
 1234            {
 41235                if (video.Video3DFormat.HasValue)
 1236                {
 01237                    terms.Add("3D");
 1238                }
 1239
 41240                if (video.VideoType == VideoType.BluRay)
 1241                {
 01242                    terms.Add("Bluray");
 1243                }
 41244                else if (video.VideoType == VideoType.Dvd)
 1245                {
 01246                    terms.Add("DVD");
 1247                }
 41248                else if (video.VideoType == VideoType.Iso)
 1249                {
 01250                    if (video.IsoType.HasValue)
 1251                    {
 01252                        if (video.IsoType.Value == IsoType.BluRay)
 1253                        {
 01254                            terms.Add("Bluray");
 1255                        }
 01256                        else if (video.IsoType.Value == IsoType.Dvd)
 1257                        {
 01258                            terms.Add("DVD");
 1259                        }
 1260                    }
 1261                    else
 1262                    {
 01263                        terms.Add("ISO");
 1264                    }
 1265                }
 1266            }
 1267
 41268            return string.Join('/', terms);
 1269        }
 1270
 1271        public Task RefreshMetadata(CancellationToken cancellationToken)
 1272        {
 481273            return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(FileSystem)), cancellationToken);
 1274        }
 1275
 1276        /// <summary>
 1277        /// The base implementation to refresh metadata.
 1278        /// </summary>
 1279        /// <param name="options">The options.</param>
 1280        /// <param name="cancellationToken">The cancellation token.</param>
 1281        /// <returns>true if a provider reports we changed.</returns>
 1282        public async Task<ItemUpdateType> RefreshMetadata(MetadataRefreshOptions options, CancellationToken cancellation
 1283        {
 1284            var requiresSave = false;
 1285
 1286            if (SupportsOwnedItems)
 1287            {
 1288                try
 1289                {
 1290                    if (IsFileProtocol)
 1291                    {
 1292                        requiresSave = await RefreshedOwnedItems(options, GetFileSystemChildren(options.DirectoryService
 1293                    }
 1294
 1295                    await LibraryManager.UpdateImagesAsync(this).ConfigureAwait(false); // ensure all image properties i
 1296                }
 1297                catch (Exception ex)
 1298                {
 1299                    Logger.LogError(ex, "Error refreshing owned items for {Path}", Path ?? Name);
 1300                }
 1301            }
 1302
 1303            var refreshOptions = requiresSave
 1304                ? new MetadataRefreshOptions(options)
 1305                {
 1306                    ForceSave = true
 1307                }
 1308                : options;
 1309
 1310            return await ProviderManager.RefreshSingleItem(this, refreshOptions, cancellationToken).ConfigureAwait(false
 1311        }
 1312
 1313        protected bool IsVisibleStandaloneInternal(User user, bool checkFolders)
 1314        {
 01315            if (!IsVisible(user))
 1316            {
 01317                return false;
 1318            }
 1319
 01320            if (GetParents().Any(i => !i.IsVisible(user, true)))
 1321            {
 01322                return false;
 1323            }
 1324
 01325            if (checkFolders)
 1326            {
 01327                var topParent = GetParents().LastOrDefault() ?? this;
 1328
 01329                if (string.IsNullOrEmpty(topParent.Path))
 1330                {
 01331                    return true;
 1332                }
 1333
 01334                var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList();
 1335
 01336                if (itemCollectionFolders.Count > 0)
 1337                {
 01338                    var userCollectionFolders = LibraryManager.GetUserRootFolder().GetChildren(user, true).Select(i => i
 01339                    if (!itemCollectionFolders.Any(userCollectionFolders.Contains))
 1340                    {
 01341                        return false;
 1342                    }
 1343                }
 1344            }
 1345
 01346            return true;
 1347        }
 1348
 1349        public void SetParent(Folder parent)
 1350        {
 111351            ParentId = parent is null ? Guid.Empty : parent.Id;
 111352        }
 1353
 1354        /// <summary>
 1355        /// Refreshes owned items such as trailers, theme videos, special features, etc.
 1356        /// Returns true or false indicating if changes were found.
 1357        /// </summary>
 1358        /// <param name="options">The metadata refresh options.</param>
 1359        /// <param name="fileSystemChildren">The list of filesystem children.</param>
 1360        /// <param name="cancellationToken">The cancellation token.</param>
 1361        /// <returns><c>true</c> if any items have changed, else <c>false</c>.</returns>
 1362        protected virtual async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, IReadOnlyList<FileSystemM
 1363        {
 1364            if (!IsFileProtocol || !SupportsOwnedItems || IsInMixedFolder || this is ICollectionFolder or UserRootFolder
 1365            {
 1366                return false;
 1367            }
 1368
 1369            return await RefreshExtras(this, options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
 1370        }
 1371
 1372        protected virtual FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService)
 1373        {
 351374            return directoryService.GetFileSystemEntries(ContainingFolderPath);
 1375        }
 1376
 1377        private async Task<bool> RefreshExtras(BaseItem item, MetadataRefreshOptions options, IReadOnlyList<FileSystemMe
 1378        {
 1379            var extras = LibraryManager.FindExtras(item, fileSystemChildren, options.DirectoryService).ToArray();
 1380            var newExtraIds = Array.ConvertAll(extras, x => x.Id);
 1381            var extrasChanged = !item.ExtraIds.SequenceEqual(newExtraIds);
 1382
 1383            if (!extrasChanged && !options.ReplaceAllMetadata && options.MetadataRefreshMode != MetadataRefreshMode.Full
 1384            {
 1385                return false;
 1386            }
 1387
 1388            var ownerId = item.Id;
 1389
 1390            var tasks = extras.Select(i =>
 1391            {
 1392                var subOptions = new MetadataRefreshOptions(options);
 1393                if (!i.OwnerId.Equals(ownerId) || !i.ParentId.IsEmpty())
 1394                {
 1395                    i.OwnerId = ownerId;
 1396                    i.ParentId = Guid.Empty;
 1397                    subOptions.ForceSave = true;
 1398                }
 1399
 1400                return RefreshMetadataForOwnedItem(i, true, subOptions, cancellationToken);
 1401            });
 1402
 1403            // Cleanup removed extras
 1404            var removedExtraIds = item.ExtraIds.Where(e => !newExtraIds.Contains(e)).ToArray();
 1405            if (removedExtraIds.Length > 0)
 1406            {
 1407                var removedExtras = LibraryManager.GetItemList(new InternalItemsQuery()
 1408                {
 1409                    ItemIds = removedExtraIds
 1410                });
 1411                foreach (var removedExtra in removedExtras)
 1412                {
 1413                    LibraryManager.DeleteItem(removedExtra, new DeleteOptions()
 1414                    {
 1415                        DeleteFileLocation = false
 1416                    });
 1417                }
 1418            }
 1419
 1420            await Task.WhenAll(tasks).ConfigureAwait(false);
 1421
 1422            item.ExtraIds = newExtraIds;
 1423
 1424            return true;
 1425        }
 1426
 1427        public string GetPresentationUniqueKey()
 1428        {
 01429            return PresentationUniqueKey ?? CreatePresentationUniqueKey();
 1430        }
 1431
 1432        public virtual bool RequiresRefresh()
 1433        {
 551434            if (string.IsNullOrEmpty(Path) || DateModified == DateTime.MinValue)
 1435            {
 01436                return false;
 1437            }
 1438
 551439            var info = FileSystem.GetFileSystemInfo(Path);
 1440
 551441            return info.Exists && this.HasChanged(info.LastWriteTimeUtc);
 1442        }
 1443
 1444        public virtual List<string> GetUserDataKeys()
 1445        {
 1021446            var list = new List<string>();
 1447
 1021448            if (SourceType == SourceType.Channel)
 1449            {
 01450                if (!string.IsNullOrEmpty(ExternalId))
 1451                {
 01452                    list.Add(ExternalId);
 1453                }
 1454            }
 1455
 1021456            list.Add(Id.ToString());
 1021457            return list;
 1458        }
 1459
 1460        internal virtual ItemUpdateType UpdateFromResolvedItem(BaseItem newItem)
 1461        {
 51462            var updateType = ItemUpdateType.None;
 1463
 51464            if (IsInMixedFolder != newItem.IsInMixedFolder)
 1465            {
 01466                IsInMixedFolder = newItem.IsInMixedFolder;
 01467                updateType |= ItemUpdateType.MetadataImport;
 1468            }
 1469
 51470            return updateType;
 1471        }
 1472
 1473        public void AfterMetadataRefresh()
 1474        {
 521475            _sortName = null;
 521476        }
 1477
 1478        /// <summary>
 1479        /// Gets the preferred metadata language.
 1480        /// </summary>
 1481        /// <returns>System.String.</returns>
 1482        public string GetPreferredMetadataLanguage()
 1483        {
 541484            string lang = PreferredMetadataLanguage;
 1485
 541486            if (string.IsNullOrEmpty(lang))
 1487            {
 541488                lang = GetParents()
 541489                    .Select(i => i.PreferredMetadataLanguage)
 541490                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1491            }
 1492
 541493            if (string.IsNullOrEmpty(lang))
 1494            {
 541495                lang = LibraryManager.GetCollectionFolders(this)
 541496                    .Select(i => i.PreferredMetadataLanguage)
 541497                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1498            }
 1499
 541500            if (string.IsNullOrEmpty(lang))
 1501            {
 541502                lang = LibraryManager.GetLibraryOptions(this).PreferredMetadataLanguage;
 1503            }
 1504
 541505            if (string.IsNullOrEmpty(lang))
 1506            {
 541507                lang = ConfigurationManager.Configuration.PreferredMetadataLanguage;
 1508            }
 1509
 541510            return lang;
 1511        }
 1512
 1513        /// <summary>
 1514        /// Gets the preferred metadata language.
 1515        /// </summary>
 1516        /// <returns>System.String.</returns>
 1517        public string GetPreferredMetadataCountryCode()
 1518        {
 541519            string lang = PreferredMetadataCountryCode;
 1520
 541521            if (string.IsNullOrEmpty(lang))
 1522            {
 541523                lang = GetParents()
 541524                    .Select(i => i.PreferredMetadataCountryCode)
 541525                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1526            }
 1527
 541528            if (string.IsNullOrEmpty(lang))
 1529            {
 541530                lang = LibraryManager.GetCollectionFolders(this)
 541531                    .Select(i => i.PreferredMetadataCountryCode)
 541532                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1533            }
 1534
 541535            if (string.IsNullOrEmpty(lang))
 1536            {
 541537                lang = LibraryManager.GetLibraryOptions(this).MetadataCountryCode;
 1538            }
 1539
 541540            if (string.IsNullOrEmpty(lang))
 1541            {
 541542                lang = ConfigurationManager.Configuration.MetadataCountryCode;
 1543            }
 1544
 541545            return lang;
 1546        }
 1547
 1548        public virtual bool IsSaveLocalMetadataEnabled()
 1549        {
 821550            if (SourceType == SourceType.Channel)
 1551            {
 01552                return false;
 1553            }
 1554
 821555            var libraryOptions = LibraryManager.GetLibraryOptions(this);
 1556
 821557            return libraryOptions.SaveLocalMetadata;
 1558        }
 1559
 1560        /// <summary>
 1561        /// Determines if a given user has access to this item.
 1562        /// </summary>
 1563        /// <param name="user">The user.</param>
 1564        /// <param name="skipAllowedTagsCheck">Don't check for allowed tags.</param>
 1565        /// <returns><c>true</c> if [is parental allowed] [the specified user]; otherwise, <c>false</c>.</returns>
 1566        /// <exception cref="ArgumentNullException">If user is null.</exception>
 1567        public bool IsParentalAllowed(User user, bool skipAllowedTagsCheck)
 1568        {
 131569            ArgumentNullException.ThrowIfNull(user);
 1570
 131571            if (!IsVisibleViaTags(user, skipAllowedTagsCheck))
 1572            {
 01573                return false;
 1574            }
 1575
 131576            var maxAllowedRating = user.MaxParentalRatingScore;
 131577            var maxAllowedSubRating = user.MaxParentalRatingSubScore;
 131578            var rating = CustomRatingForComparison;
 1579
 131580            if (string.IsNullOrEmpty(rating))
 1581            {
 131582                rating = OfficialRatingForComparison;
 1583            }
 1584
 131585            if (string.IsNullOrEmpty(rating))
 1586            {
 131587                Logger.LogDebug("{0} has no parental rating set.", Name);
 131588                return !GetBlockUnratedValue(user);
 1589            }
 1590
 01591            var ratingScore = LocalizationManager.GetRatingScore(rating);
 1592
 1593            // Could not determine rating level
 01594            if (ratingScore is null)
 1595            {
 01596                var isAllowed = !GetBlockUnratedValue(user);
 1597
 01598                if (!isAllowed)
 1599                {
 01600                    Logger.LogDebug("{0} has an unrecognized parental rating of {1}.", Name, rating);
 1601                }
 1602
 01603                return isAllowed;
 1604            }
 1605
 01606            if (maxAllowedSubRating is not null)
 1607            {
 01608                return (ratingScore.SubScore ?? 0) <= maxAllowedSubRating && ratingScore.Score <= maxAllowedRating.Value
 1609            }
 1610
 01611            return !maxAllowedRating.HasValue || ratingScore.Score <= maxAllowedRating.Value;
 1612        }
 1613
 1614        public ParentalRatingScore GetParentalRatingScore()
 1615        {
 1081616            var rating = CustomRatingForComparison;
 1617
 1081618            if (string.IsNullOrEmpty(rating))
 1619            {
 1081620                rating = OfficialRatingForComparison;
 1621            }
 1622
 1081623            if (string.IsNullOrEmpty(rating))
 1624            {
 1081625                return null;
 1626            }
 1627
 01628            return LocalizationManager.GetRatingScore(rating);
 1629        }
 1630
 1631        public List<string> GetInheritedTags()
 1632        {
 1061633            var list = new List<string>();
 1061634            list.AddRange(Tags);
 1635
 2581636            foreach (var parent in GetParents())
 1637            {
 231638                list.AddRange(parent.Tags);
 1639            }
 1640
 2121641            foreach (var folder in LibraryManager.GetCollectionFolders(this))
 1642            {
 01643                list.AddRange(folder.Tags);
 1644            }
 1645
 1061646            return list.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
 1647        }
 1648
 1649        private bool IsVisibleViaTags(User user, bool skipAllowedTagsCheck)
 1650        {
 131651            var allTags = GetInheritedTags();
 131652            if (user.GetPreference(PreferenceKind.BlockedTags).Any(i => allTags.Contains(i, StringComparison.OrdinalIgno
 1653            {
 01654                return false;
 1655            }
 1656
 131657            var parent = GetParents().FirstOrDefault() ?? this;
 131658            if (parent is UserRootFolder or AggregateFolder or UserView)
 1659            {
 131660                return true;
 1661            }
 1662
 01663            var allowedTagsPreference = user.GetPreference(PreferenceKind.AllowedTags);
 01664            if (!skipAllowedTagsCheck && allowedTagsPreference.Length != 0 && !allowedTagsPreference.Any(i => allTags.Co
 1665            {
 01666                return false;
 1667            }
 1668
 01669            return true;
 1670        }
 1671
 1672        public virtual UnratedItem GetBlockUnratedType()
 1673        {
 931674            if (SourceType == SourceType.Channel)
 1675            {
 01676                return UnratedItem.ChannelContent;
 1677            }
 1678
 931679            return UnratedItem.Other;
 1680        }
 1681
 1682        /// <summary>
 1683        /// Gets a bool indicating if access to the unrated item is blocked or not.
 1684        /// </summary>
 1685        /// <param name="user">The configuration.</param>
 1686        /// <returns><c>true</c> if blocked, <c>false</c> otherwise.</returns>
 1687        protected virtual bool GetBlockUnratedValue(User user)
 1688        {
 1689            // Don't block plain folders that are unrated. Let the media underneath get blocked
 1690            // Special folders like series and albums will override this method.
 131691            if (IsFolder || this is IItemByName)
 1692            {
 131693                return false;
 1694            }
 1695
 01696            return user.GetPreferenceValues<UnratedItem>(PreferenceKind.BlockUnratedItems).Contains(GetBlockUnratedType(
 1697        }
 1698
 1699        /// <summary>
 1700        /// Determines if this folder should be visible to a given user.
 1701        /// Default is just parental allowed. Can be overridden for more functionality.
 1702        /// </summary>
 1703        /// <param name="user">The user.</param>
 1704        /// <param name="skipAllowedTagsCheck">Don't check for allowed tags.</param>
 1705        /// <returns><c>true</c> if the specified user is visible; otherwise, <c>false</c>.</returns>
 1706        /// <exception cref="ArgumentNullException"><paramref name="user" /> is <c>null</c>.</exception>
 1707        public virtual bool IsVisible(User user, bool skipAllowedTagsCheck = false)
 1708        {
 131709            ArgumentNullException.ThrowIfNull(user);
 1710
 131711            return IsParentalAllowed(user, skipAllowedTagsCheck);
 1712        }
 1713
 1714        public virtual bool IsVisibleStandalone(User user)
 1715        {
 01716            if (SourceType == SourceType.Channel)
 1717            {
 01718                return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
 1719            }
 1720
 01721            return IsVisibleStandaloneInternal(user, true);
 1722        }
 1723
 1724        public virtual string GetClientTypeName()
 1725        {
 781726            if (IsFolder && SourceType == SourceType.Channel && this is not Channel && this is not Season && this is not
 1727            {
 01728                return "ChannelFolderItem";
 1729            }
 1730
 781731            return GetType().Name;
 1732        }
 1733
 1734        public BaseItemKind GetBaseItemKind()
 1735        {
 2511736            return _baseItemKind ??= Enum.Parse<BaseItemKind>(GetClientTypeName());
 1737        }
 1738
 1739        /// <summary>
 1740        /// Gets the linked child.
 1741        /// </summary>
 1742        /// <param name="info">The info.</param>
 1743        /// <returns>BaseItem.</returns>
 1744        protected BaseItem GetLinkedChild(LinkedChild info)
 1745        {
 1746            // First get using the cached Id
 01747            if (info.ItemId.HasValue)
 1748            {
 01749                if (info.ItemId.Value.IsEmpty())
 1750                {
 01751                    return null;
 1752                }
 1753
 01754                var itemById = LibraryManager.GetItemById(info.ItemId.Value);
 1755
 01756                if (itemById is not null)
 1757                {
 01758                    return itemById;
 1759                }
 1760            }
 1761
 01762            var item = FindLinkedChild(info);
 1763
 1764            // If still null, log
 01765            if (item is null)
 1766            {
 1767                // Don't keep searching over and over
 01768                info.ItemId = Guid.Empty;
 1769            }
 1770            else
 1771            {
 1772                // Cache the id for next time
 01773                info.ItemId = item.Id;
 1774            }
 1775
 01776            return item;
 1777        }
 1778
 1779        private BaseItem FindLinkedChild(LinkedChild info)
 1780        {
 01781            var path = info.Path;
 1782
 01783            if (!string.IsNullOrEmpty(path))
 1784            {
 01785                path = FileSystem.MakeAbsolutePath(ContainingFolderPath, path);
 1786
 01787                var itemByPath = LibraryManager.FindByPath(path, null);
 1788
 01789                if (itemByPath is null)
 1790                {
 01791                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1792                }
 1793
 01794                return itemByPath;
 1795            }
 1796
 01797            if (!string.IsNullOrEmpty(info.LibraryItemId))
 1798            {
 01799                var item = LibraryManager.GetItemById(info.LibraryItemId);
 1800
 01801                if (item is null)
 1802                {
 01803                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1804                }
 1805
 01806                return item;
 1807            }
 1808
 01809            return null;
 1810        }
 1811
 1812        /// <summary>
 1813        /// Adds a studio to the item.
 1814        /// </summary>
 1815        /// <param name="name">The name.</param>
 1816        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1817        public void AddStudio(string name)
 1818        {
 41819            ArgumentException.ThrowIfNullOrEmpty(name);
 41820            var current = Studios;
 1821
 41822            if (!current.Contains(name, StringComparison.OrdinalIgnoreCase))
 1823            {
 41824                int curLen = current.Length;
 41825                if (curLen == 0)
 1826                {
 41827                    Studios = [name];
 1828                }
 1829                else
 1830                {
 01831                    Studios = [.. current, name];
 1832                }
 1833            }
 01834        }
 1835
 1836        public void SetStudios(IEnumerable<string> names)
 1837        {
 01838            Studios = names.Trimmed().Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
 01839        }
 1840
 1841        /// <summary>
 1842        /// Adds a genre to the item.
 1843        /// </summary>
 1844        /// <param name="name">The name.</param>
 1845        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1846        public void AddGenre(string name)
 1847        {
 131848            ArgumentException.ThrowIfNullOrEmpty(name);
 1849
 131850            var genres = Genres;
 131851            if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))
 1852            {
 131853                Genres = [.. genres, name];
 1854            }
 131855        }
 1856
 1857        /// <summary>
 1858        /// Marks the played.
 1859        /// </summary>
 1860        /// <param name="user">The user.</param>
 1861        /// <param name="datePlayed">The date played.</param>
 1862        /// <param name="resetPosition">if set to <c>true</c> [reset position].</param>
 1863        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1864        public virtual void MarkPlayed(
 1865            User user,
 1866            DateTime? datePlayed,
 1867            bool resetPosition)
 1868        {
 01869            ArgumentNullException.ThrowIfNull(user);
 1870
 01871            var data = UserDataManager.GetUserData(user, this) ?? new UserItemData()
 01872            {
 01873                Key = GetUserDataKeys().First(),
 01874            };
 1875
 01876            if (datePlayed.HasValue)
 1877            {
 1878                // Increment
 01879                data.PlayCount++;
 1880            }
 1881
 1882            // Ensure it's at least one
 01883            data.PlayCount = Math.Max(data.PlayCount, 1);
 1884
 01885            if (resetPosition)
 1886            {
 01887                data.PlaybackPositionTicks = 0;
 1888            }
 1889
 01890            data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
 01891            data.Played = true;
 1892
 01893            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01894        }
 1895
 1896        /// <summary>
 1897        /// Marks the unplayed.
 1898        /// </summary>
 1899        /// <param name="user">The user.</param>
 1900        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1901        public virtual void MarkUnplayed(User user)
 1902        {
 01903            ArgumentNullException.ThrowIfNull(user);
 1904
 01905            var data = UserDataManager.GetUserData(user, this);
 1906
 1907            // I think it is okay to do this here.
 1908            // if this is only called when a user is manually forcing something to un-played
 1909            // then it probably is what we want to do...
 01910            data.PlayCount = 0;
 01911            data.PlaybackPositionTicks = 0;
 01912            data.LastPlayedDate = null;
 01913            data.Played = false;
 1914
 01915            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01916        }
 1917
 1918        /// <summary>
 1919        /// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed.
 1920        /// </summary>
 1921        public virtual void ChangedExternally()
 1922        {
 01923            ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem)), RefreshPriori
 01924        }
 1925
 1926        /// <summary>
 1927        /// Gets an image.
 1928        /// </summary>
 1929        /// <param name="type">The type.</param>
 1930        /// <param name="imageIndex">Index of the image.</param>
 1931        /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
 1932        /// <exception cref="ArgumentException">Backdrops should be accessed using Item.Backdrops.</exception>
 1933        public bool HasImage(ImageType type, int imageIndex)
 1934        {
 1431935            return GetImageInfo(type, imageIndex) is not null;
 1936        }
 1937
 1938        public void SetImage(ItemImageInfo image, int index)
 1939        {
 131940            if (image.Type == ImageType.Chapter)
 1941            {
 01942                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1943            }
 1944
 131945            var existingImage = GetImageInfo(image.Type, index);
 1946
 131947            if (existingImage is null)
 1948            {
 111949                AddImage(image);
 1950            }
 1951            else
 1952            {
 21953                existingImage.Path = image.Path;
 21954                existingImage.DateModified = image.DateModified;
 21955                existingImage.Width = image.Width;
 21956                existingImage.Height = image.Height;
 21957                existingImage.BlurHash = image.BlurHash;
 1958            }
 21959        }
 1960
 1961        public void SetImagePath(ImageType type, int index, FileSystemMetadata file)
 1962        {
 461963            if (type == ImageType.Chapter)
 1964            {
 01965                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1966            }
 1967
 461968            var image = GetImageInfo(type, index);
 1969
 461970            if (image is null)
 1971            {
 451972                AddImage(GetImageInfo(file, type));
 1973            }
 1974            else
 1975            {
 11976                var imageInfo = GetImageInfo(file, type);
 1977
 11978                image.Path = file.FullName;
 11979                image.DateModified = imageInfo.DateModified;
 1980
 1981                // reset these values
 11982                image.Width = 0;
 11983                image.Height = 0;
 1984            }
 11985        }
 1986
 1987        /// <summary>
 1988        /// Deletes the image.
 1989        /// </summary>
 1990        /// <param name="type">The type.</param>
 1991        /// <param name="index">The index.</param>
 1992        /// <returns>A task.</returns>
 1993        public async Task DeleteImageAsync(ImageType type, int index)
 1994        {
 1995            var info = GetImageInfo(type, index);
 1996
 1997            if (info is null)
 1998            {
 1999                // Nothing to do
 2000                return;
 2001            }
 2002
 2003            // Remove from file system
 2004            var path = info.Path;
 2005            if (info.IsLocalFile && !string.IsNullOrWhiteSpace(path))
 2006            {
 2007                FileSystem.DeleteFile(path);
 2008            }
 2009
 2010            // Remove from item
 2011            RemoveImage(info);
 2012
 2013            await UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None).ConfigureAwait(false);
 2014        }
 2015
 2016        public void RemoveImage(ItemImageInfo image)
 2017        {
 02018            RemoveImages([image]);
 02019        }
 2020
 2021        public void RemoveImages(IEnumerable<ItemImageInfo> deletedImages)
 2022        {
 92023            ImageInfos = ImageInfos.Except(deletedImages).ToArray();
 92024        }
 2025
 2026        public void AddImage(ItemImageInfo image)
 2027        {
 562028            ImageInfos = [.. ImageInfos, image];
 562029        }
 2030
 2031        public virtual async Task UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationTok
 2032         => await LibraryManager.UpdateItemAsync(this, GetParent(), updateReason, cancellationToken).ConfigureAwait(fals
 2033
 2034        /// <summary>
 2035        /// Validates that images within the item are still on the filesystem.
 2036        /// </summary>
 2037        /// <returns><c>true</c> if the images validate, <c>false</c> if not.</returns>
 2038        public bool ValidateImages()
 2039        {
 682040            List<ItemImageInfo> deletedImages = null;
 1662041            foreach (var imageInfo in ImageInfos)
 2042            {
 152043                if (!imageInfo.IsLocalFile)
 2044                {
 2045                    continue;
 2046                }
 2047
 152048                if (File.Exists(imageInfo.Path))
 2049                {
 2050                    continue;
 2051                }
 2052
 32053                (deletedImages ??= []).Add(imageInfo);
 2054            }
 2055
 682056            var anyImagesRemoved = deletedImages?.Count > 0;
 682057            if (anyImagesRemoved)
 2058            {
 22059                RemoveImages(deletedImages);
 2060            }
 2061
 682062            return anyImagesRemoved;
 2063        }
 2064
 2065        /// <summary>
 2066        /// Gets the image path.
 2067        /// </summary>
 2068        /// <param name="imageType">Type of the image.</param>
 2069        /// <param name="imageIndex">Index of the image.</param>
 2070        /// <returns>System.String.</returns>
 2071        /// <exception cref="ArgumentNullException">Item is null.</exception>
 2072        public string GetImagePath(ImageType imageType, int imageIndex)
 22073            => GetImageInfo(imageType, imageIndex)?.Path;
 2074
 2075        /// <summary>
 2076        /// Gets the image information.
 2077        /// </summary>
 2078        /// <param name="imageType">Type of the image.</param>
 2079        /// <param name="imageIndex">Index of the image.</param>
 2080        /// <returns>ItemImageInfo.</returns>
 2081        public ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex)
 2082        {
 3132083            if (imageType == ImageType.Chapter)
 2084            {
 02085                var chapter = ChapterManager.GetChapter(Id, imageIndex);
 2086
 02087                if (chapter is null)
 2088                {
 02089                    return null;
 2090                }
 2091
 02092                var path = chapter.ImagePath;
 2093
 02094                if (string.IsNullOrEmpty(path))
 2095                {
 02096                    return null;
 2097                }
 2098
 02099                return new ItemImageInfo
 02100                {
 02101                    Path = path,
 02102                    DateModified = chapter.ImageDateModified,
 02103                    Type = imageType
 02104                };
 2105            }
 2106
 2107            // Music albums usually don't have dedicated backdrops, so return one from the artist instead
 3132108            if (GetType() == typeof(MusicAlbum) && imageType == ImageType.Backdrop)
 2109            {
 02110                var artist = FindParent<MusicArtist>();
 2111
 02112                if (artist is not null)
 2113                {
 02114                    return artist.GetImages(imageType).ElementAtOrDefault(imageIndex);
 2115                }
 2116            }
 2117
 3132118            return GetImages(imageType)
 3132119                .ElementAtOrDefault(imageIndex);
 2120        }
 2121
 2122        /// <summary>
 2123        /// Computes image index for given image or raises if no matching image found.
 2124        /// </summary>
 2125        /// <param name="image">Image to compute index for.</param>
 2126        /// <exception cref="ArgumentException">Image index cannot be computed as no matching image found.
 2127        /// </exception>
 2128        /// <returns>Image index.</returns>
 2129        public int GetImageIndex(ItemImageInfo image)
 2130        {
 02131            ArgumentNullException.ThrowIfNull(image);
 2132
 02133            if (image.Type == ImageType.Chapter)
 2134            {
 02135                var chapters = ChapterManager.GetChapters(Id);
 02136                for (var i = 0; i < chapters.Count; i++)
 2137                {
 02138                    if (chapters[i].ImagePath == image.Path)
 2139                    {
 02140                        return i;
 2141                    }
 2142                }
 2143
 02144                throw new ArgumentException("No chapter index found for image path", image.Path);
 2145            }
 2146
 02147            var images = GetImages(image.Type).ToArray();
 02148            for (var i = 0; i < images.Length; i++)
 2149            {
 02150                if (images[i].Path == image.Path)
 2151                {
 02152                    return i;
 2153                }
 2154            }
 2155
 02156            throw new ArgumentException("No image index found for image path", image.Path);
 2157        }
 2158
 2159        public IEnumerable<ItemImageInfo> GetImages(ImageType imageType)
 2160        {
 2161            if (imageType == ImageType.Chapter)
 2162            {
 2163                throw new ArgumentException("No image info for chapter images");
 2164            }
 2165
 2166            // Yield return is more performant than LINQ Where on an Array
 2167            for (var i = 0; i < ImageInfos.Length; i++)
 2168            {
 2169                var imageInfo = ImageInfos[i];
 2170                if (imageInfo.Type == imageType)
 2171                {
 2172                    yield return imageInfo;
 2173                }
 2174            }
 2175        }
 2176
 2177        /// <summary>
 2178        /// Adds the images, updating metadata if they already are part of this item.
 2179        /// </summary>
 2180        /// <param name="imageType">Type of the image.</param>
 2181        /// <param name="images">The images.</param>
 2182        /// <returns><c>true</c> if images were added or updated, <c>false</c> otherwise.</returns>
 2183        /// <exception cref="ArgumentException">Cannot call AddImages with chapter images.</exception>
 2184        public bool AddImages(ImageType imageType, List<FileSystemMetadata> images)
 2185        {
 682186            if (imageType == ImageType.Chapter)
 2187            {
 02188                throw new ArgumentException("Cannot call AddImages with chapter images");
 2189            }
 2190
 682191            var existingImages = GetImages(imageType)
 682192                .ToList();
 2193
 682194            var newImageList = new List<FileSystemMetadata>();
 682195            var imageUpdated = false;
 2196
 1522197            foreach (var newImage in images)
 2198            {
 82199                if (newImage is null)
 2200                {
 02201                    throw new ArgumentException("null image found in list");
 2202                }
 2203
 82204                var existing = existingImages
 82205                    .Find(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase));
 2206
 82207                if (existing is null)
 2208                {
 42209                    newImageList.Add(newImage);
 2210                }
 2211                else
 2212                {
 42213                    if (existing.IsLocalFile)
 2214                    {
 42215                        var newDateModified = FileSystem.GetLastWriteTimeUtc(newImage);
 2216
 2217                        // If date changed then we need to reset saved image dimensions
 42218                        if (existing.DateModified != newDateModified && (existing.Width > 0 || existing.Height > 0))
 2219                        {
 22220                            existing.Width = 0;
 22221                            existing.Height = 0;
 22222                            imageUpdated = true;
 2223                        }
 2224
 42225                        existing.DateModified = newDateModified;
 2226                    }
 2227                }
 2228            }
 2229
 682230            if (newImageList.Count > 0)
 2231            {
 22232                ImageInfos = ImageInfos.Concat(newImageList.Select(i => GetImageInfo(i, imageType))).ToArray();
 2233            }
 2234
 682235            return imageUpdated || newImageList.Count > 0;
 2236        }
 2237
 2238        private ItemImageInfo GetImageInfo(FileSystemMetadata file, ImageType type)
 2239        {
 502240            return new ItemImageInfo
 502241            {
 502242                Path = file.FullName,
 502243                Type = type,
 502244                DateModified = FileSystem.GetLastWriteTimeUtc(file)
 502245            };
 2246        }
 2247
 2248        /// <summary>
 2249        /// Gets the file system path to delete when the item is to be deleted.
 2250        /// </summary>
 2251        /// <returns>The metadata for the deleted paths.</returns>
 2252        public virtual IEnumerable<FileSystemMetadata> GetDeletePaths()
 2253        {
 02254            return new[]
 02255            {
 02256                FileSystem.GetFileSystemInfo(Path)
 02257            }.Concat(GetLocalMetadataFilesToDelete());
 2258        }
 2259
 2260        protected List<FileSystemMetadata> GetLocalMetadataFilesToDelete()
 2261        {
 02262            if (IsFolder || !IsInMixedFolder)
 2263            {
 02264                return [];
 2265            }
 2266
 02267            var filename = System.IO.Path.GetFileNameWithoutExtension(Path);
 2268
 02269            return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), _supportedExtensions, false, false)
 02270                .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison
 02271                .ToList();
 2272        }
 2273
 2274        public bool AllowsMultipleImages(ImageType type)
 2275        {
 182276            return type == ImageType.Backdrop || type == ImageType.Chapter;
 2277        }
 2278
 2279        public Task SwapImagesAsync(ImageType type, int index1, int index2)
 2280        {
 02281            if (!AllowsMultipleImages(type))
 2282            {
 02283                throw new ArgumentException("The change index operation is only applicable to backdrops and screen shots
 2284            }
 2285
 02286            var info1 = GetImageInfo(type, index1);
 02287            var info2 = GetImageInfo(type, index2);
 2288
 02289            if (info1 is null || info2 is null)
 2290            {
 2291                // Nothing to do
 02292                return Task.CompletedTask;
 2293            }
 2294
 02295            if (!info1.IsLocalFile || !info2.IsLocalFile)
 2296            {
 2297                // TODO: Not supported  yet
 02298                return Task.CompletedTask;
 2299            }
 2300
 02301            var path1 = info1.Path;
 02302            var path2 = info2.Path;
 2303
 02304            FileSystem.SwapFiles(path1, path2);
 2305
 2306            // Refresh these values
 02307            info1.DateModified = FileSystem.GetLastWriteTimeUtc(info1.Path);
 02308            info2.DateModified = FileSystem.GetLastWriteTimeUtc(info2.Path);
 2309
 02310            info1.Width = 0;
 02311            info1.Height = 0;
 02312            info2.Width = 0;
 02313            info2.Height = 0;
 2314
 02315            return UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None);
 2316        }
 2317
 2318        public virtual bool IsPlayed(User user, UserItemData userItemData)
 2319        {
 02320            userItemData ??= UserDataManager.GetUserData(user, this);
 2321
 02322            return userItemData is not null && userItemData.Played;
 2323        }
 2324
 2325        public bool IsFavoriteOrLiked(User user, UserItemData userItemData)
 2326        {
 02327            userItemData ??= UserDataManager.GetUserData(user, this);
 2328
 02329            return userItemData is not null && (userItemData.IsFavorite || (userItemData.Likes ?? false));
 2330        }
 2331
 2332        public virtual bool IsUnplayed(User user, UserItemData userItemData)
 2333        {
 02334            ArgumentNullException.ThrowIfNull(user);
 2335
 02336            userItemData ??= UserDataManager.GetUserData(user, this);
 2337
 02338            return userItemData is null || !userItemData.Played;
 2339        }
 2340
 2341        ItemLookupInfo IHasLookupInfo<ItemLookupInfo>.GetLookupInfo()
 2342        {
 542343            return GetItemLookupInfo<ItemLookupInfo>();
 2344        }
 2345
 2346        protected T GetItemLookupInfo<T>()
 2347            where T : ItemLookupInfo, new()
 2348        {
 542349            return new T
 542350            {
 542351                Path = Path,
 542352                MetadataCountryCode = GetPreferredMetadataCountryCode(),
 542353                MetadataLanguage = GetPreferredMetadataLanguage(),
 542354                Name = GetNameForMetadataLookup(),
 542355                OriginalTitle = OriginalTitle,
 542356                ProviderIds = ProviderIds,
 542357                IndexNumber = IndexNumber,
 542358                ParentIndexNumber = ParentIndexNumber,
 542359                Year = ProductionYear,
 542360                PremiereDate = PremiereDate
 542361            };
 2362        }
 2363
 2364        protected virtual string GetNameForMetadataLookup()
 2365        {
 542366            return Name;
 2367        }
 2368
 2369        /// <summary>
 2370        /// This is called before any metadata refresh and returns true if changes were made.
 2371        /// </summary>
 2372        /// <param name="replaceAllMetadata">Whether to replace all metadata.</param>
 2373        /// <returns>true if the item has change, else false.</returns>
 2374        public virtual bool BeforeMetadataRefresh(bool replaceAllMetadata)
 2375        {
 542376            _sortName = null;
 2377
 542378            var hasChanges = false;
 2379
 542380            if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path))
 2381            {
 02382                Name = System.IO.Path.GetFileNameWithoutExtension(Path);
 02383                hasChanges = true;
 2384            }
 2385
 542386            return hasChanges;
 2387        }
 2388
 2389        protected static string GetMappedPath(BaseItem item, string path, MediaProtocol? protocol)
 2390        {
 02391            if (protocol == MediaProtocol.File)
 2392            {
 02393                return LibraryManager.GetPathAfterNetworkSubstitution(path, item);
 2394            }
 2395
 02396            return path;
 2397        }
 2398
 2399        public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User 
 2400        {
 02401            if (RunTimeTicks.HasValue)
 2402            {
 02403                double pct = RunTimeTicks.Value;
 2404
 02405                if (pct > 0)
 2406                {
 02407                    pct = userData.PlaybackPositionTicks / pct;
 2408
 02409                    if (pct > 0)
 2410                    {
 02411                        dto.PlayedPercentage = 100 * pct;
 2412                    }
 2413                }
 2414            }
 02415        }
 2416
 2417        protected async Task RefreshMetadataForOwnedItem(BaseItem ownedItem, bool copyTitleMetadata, MetadataRefreshOpti
 2418        {
 2419            var newOptions = new MetadataRefreshOptions(options)
 2420            {
 2421                SearchResult = null
 2422            };
 2423
 2424            var item = this;
 2425
 2426            if (copyTitleMetadata)
 2427            {
 2428                // Take some data from the main item, for querying purposes
 2429                if (!item.Genres.SequenceEqual(ownedItem.Genres, StringComparer.Ordinal))
 2430                {
 2431                    newOptions.ForceSave = true;
 2432                    ownedItem.Genres = item.Genres;
 2433                }
 2434
 2435                if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal))
 2436                {
 2437                    newOptions.ForceSave = true;
 2438                    ownedItem.Studios = item.Studios;
 2439                }
 2440
 2441                if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal))
 2442                {
 2443                    newOptions.ForceSave = true;
 2444                    ownedItem.ProductionLocations = item.ProductionLocations;
 2445                }
 2446
 2447                if (item.CommunityRating != ownedItem.CommunityRating)
 2448                {
 2449                    ownedItem.CommunityRating = item.CommunityRating;
 2450                    newOptions.ForceSave = true;
 2451                }
 2452
 2453                if (item.CriticRating != ownedItem.CriticRating)
 2454                {
 2455                    ownedItem.CriticRating = item.CriticRating;
 2456                    newOptions.ForceSave = true;
 2457                }
 2458
 2459                if (!string.Equals(item.Overview, ownedItem.Overview, StringComparison.Ordinal))
 2460                {
 2461                    ownedItem.Overview = item.Overview;
 2462                    newOptions.ForceSave = true;
 2463                }
 2464
 2465                if (!string.Equals(item.OfficialRating, ownedItem.OfficialRating, StringComparison.Ordinal))
 2466                {
 2467                    ownedItem.OfficialRating = item.OfficialRating;
 2468                    newOptions.ForceSave = true;
 2469                }
 2470
 2471                if (!string.Equals(item.CustomRating, ownedItem.CustomRating, StringComparison.Ordinal))
 2472                {
 2473                    ownedItem.CustomRating = item.CustomRating;
 2474                    newOptions.ForceSave = true;
 2475                }
 2476            }
 2477
 2478            await ownedItem.RefreshMetadata(newOptions, cancellationToken).ConfigureAwait(false);
 2479        }
 2480
 2481        protected async Task RefreshMetadataForOwnedVideo(MetadataRefreshOptions options, bool copyTitleMetadata, string
 2482        {
 2483            var newOptions = new MetadataRefreshOptions(options)
 2484            {
 2485                SearchResult = null
 2486            };
 2487
 2488            var id = LibraryManager.GetNewItemId(path, typeof(Video));
 2489
 2490            // Try to retrieve it from the db. If we don't find it, use the resolved version
 2491            if (LibraryManager.GetItemById(id) is not Video video)
 2492            {
 2493                video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video;
 2494
 2495                newOptions.ForceSave = true;
 2496            }
 2497
 2498            if (video is null)
 2499            {
 2500                return;
 2501            }
 2502
 2503            if (video.OwnerId.IsEmpty())
 2504            {
 2505                video.OwnerId = Id;
 2506            }
 2507
 2508            await RefreshMetadataForOwnedItem(video, copyTitleMetadata, newOptions, cancellationToken).ConfigureAwait(fa
 2509        }
 2510
 2511        public string GetEtag(User user)
 2512        {
 62513            var list = GetEtagValues(user);
 2514
 62515            return string.Join('|', list).GetMD5().ToString("N", CultureInfo.InvariantCulture);
 2516        }
 2517
 2518        protected virtual List<string> GetEtagValues(User user)
 2519        {
 62520            return
 62521            [
 62522                DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture)
 62523            ];
 2524        }
 2525
 2526        public virtual IEnumerable<Guid> GetAncestorIds()
 2527        {
 932528            return GetParents().Select(i => i.Id).Concat(LibraryManager.GetCollectionFolders(this).Select(i => i.Id));
 2529        }
 2530
 2531        public BaseItem GetTopParent()
 2532        {
 932533            if (IsTopParent)
 2534            {
 212535                return this;
 2536            }
 2537
 722538            return GetParents().FirstOrDefault(parent => parent.IsTopParent);
 2539        }
 2540
 2541        public virtual IEnumerable<Guid> GetIdsForAncestorQuery()
 2542        {
 422543            return [Id];
 2544        }
 2545
 2546        public virtual double? GetRefreshProgress()
 2547        {
 02548            return null;
 2549        }
 2550
 2551        public virtual ItemUpdateType OnMetadataChanged()
 2552        {
 1082553            var updateType = ItemUpdateType.None;
 2554
 1082555            var item = this;
 2556
 1082557            var rating = item.GetParentalRatingScore();
 1082558            if (rating is not null)
 2559            {
 02560                if (rating.Score != item.InheritedParentalRatingValue)
 2561                {
 02562                    item.InheritedParentalRatingValue = rating.Score;
 02563                    updateType |= ItemUpdateType.MetadataImport;
 2564                }
 2565
 02566                if (rating.SubScore != item.InheritedParentalRatingSubValue)
 2567                {
 02568                    item.InheritedParentalRatingSubValue = rating.SubScore;
 02569                    updateType |= ItemUpdateType.MetadataImport;
 2570                }
 2571            }
 2572            else
 2573            {
 1082574                if (item.InheritedParentalRatingValue is not null)
 2575                {
 02576                    item.InheritedParentalRatingValue = null;
 02577                    item.InheritedParentalRatingSubValue = null;
 02578                    updateType |= ItemUpdateType.MetadataImport;
 2579                }
 2580            }
 2581
 1082582            return updateType;
 2583        }
 2584
 2585        /// <summary>
 2586        /// Updates the official rating based on content and returns true or false indicating if it changed.
 2587        /// </summary>
 2588        /// <param name="children">Media children.</param>
 2589        /// <returns><c>true</c> if the rating was updated; otherwise <c>false</c>.</returns>
 2590        public bool UpdateRatingToItems(IReadOnlyList<BaseItem> children)
 2591        {
 02592            var currentOfficialRating = OfficialRating;
 2593
 2594            // Gather all possible ratings
 02595            var ratings = children
 02596                .Select(i => i.OfficialRating)
 02597                .Where(i => !string.IsNullOrEmpty(i))
 02598                .Distinct(StringComparer.OrdinalIgnoreCase)
 02599                .Select(rating => (rating, LocalizationManager.GetRatingScore(rating)))
 02600                .OrderBy(i => i.Item2 is null ? 1001 : i.Item2.Score)
 02601                .ThenBy(i => i.Item2 is null ? 1001 : i.Item2.SubScore)
 02602                .Select(i => i.rating);
 2603
 02604            OfficialRating = ratings.FirstOrDefault() ?? currentOfficialRating;
 2605
 02606            return !string.Equals(
 02607                currentOfficialRating ?? string.Empty,
 02608                OfficialRating ?? string.Empty,
 02609                StringComparison.OrdinalIgnoreCase);
 2610        }
 2611
 2612        public IReadOnlyList<BaseItem> GetThemeSongs(User user = null)
 2613        {
 02614            return GetThemeSongs(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2615        }
 2616
 2617        public IReadOnlyList<BaseItem> GetThemeSongs(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> or
 2618        {
 02619            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeSong), user, 
 2620        }
 2621
 2622        public IReadOnlyList<BaseItem> GetThemeVideos(User user = null)
 2623        {
 02624            return GetThemeVideos(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2625        }
 2626
 2627        public IReadOnlyList<BaseItem> GetThemeVideos(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> o
 2628        {
 02629            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeVideo), user,
 2630        }
 2631
 2632        /// <summary>
 2633        /// Get all extras associated with this item, sorted by <see cref="SortName"/>.
 2634        /// </summary>
 2635        /// <returns>An enumerable containing the items.</returns>
 2636        public IEnumerable<BaseItem> GetExtras()
 2637        {
 62638            return ExtraIds
 62639                .Select(LibraryManager.GetItemById)
 62640                .Where(i => i is not null)
 62641                .OrderBy(i => i.SortName);
 2642        }
 2643
 2644        /// <summary>
 2645        /// Get all extras with specific types that are associated with this item.
 2646        /// </summary>
 2647        /// <param name="extraTypes">The types of extras to retrieve.</param>
 2648        /// <returns>An enumerable containing the extras.</returns>
 2649        public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
 2650        {
 02651            return ExtraIds
 02652                .Select(LibraryManager.GetItemById)
 02653                .Where(i => i is not null)
 02654                .Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value))
 02655                .OrderBy(i => i.SortName);
 2656        }
 2657
 2658        public virtual long GetRunTimeTicksForPlayState()
 2659        {
 02660            return RunTimeTicks ?? 0;
 2661        }
 2662
 2663        /// <inheritdoc />
 2664        public override bool Equals(object obj)
 2665        {
 02666            return obj is BaseItem baseItem && this.Equals(baseItem);
 2667        }
 2668
 2669        /// <inheritdoc />
 52670        public bool Equals(BaseItem other) => other is not null && other.Id.Equals(Id);
 2671
 2672        /// <inheritdoc />
 522673        public override int GetHashCode() => HashCode.Combine(Id);
 2674    }
 2675}

Methods/Properties

.cctor()
.ctor()
get_SupportsAddingToPlaylist()
get_AlwaysScanInternalMetadataPath()
get_SupportsPlayedStatus()
get_SupportsPositionTicksResume()
get_SupportsRemoteImageDownloading()
get_Name()
set_Name(System.String)
get_IsUnaired()
get_IsThemeMedia()
get_DisplayPreferencesId()
get_SourceType()
get_ContainingFolderPath()
get_IsHidden()
get_LocationType()
get_PathProtocol()
get_IsFileProtocol()
get_HasPathProtocol()
get_SupportsLocalMetadata()
get_FileNameWithoutExtension()
get_EnableAlphaNumericSorting()
get_IsHD()
get_PrimaryImagePath()
get_MediaType()
get_PhysicalLocations()
get_EnableMediaSourceDisplay()
get_ForcedSortName()
set_ForcedSortName(System.String)
get_SortName()
set_SortName(System.String)
get_DisplayParentId()
get_DisplayParent()
get_HasLocalAlternateVersions()
get_OfficialRatingForComparison()
get_CustomRatingForComparison()
get_LatestItemsIndexContainer()
get_EnableRememberingTrackSelections()
get_IsTopParent()
get_SupportsAncestors()
get_SupportsOwnedItems()
get_SupportsPeople()
get_SupportsThemeMedia()
get_SupportsInheritedParentImages()
get_IsFolder()
get_IsDisplayedAsFolder()
GetCustomRatingForComparision(System.Collections.Generic.HashSet`1<System.Guid>)
GetDefaultPrimaryImageAspectRatio()
CreatePresentationUniqueKey()
CanDelete()
IsAuthorizedToDelete(Jellyfin.Database.Implementations.Entities.User,System.Collections.Generic.List`1<MediaBrowser.Controller.Entities.Folder>)
GetOwner()
CanDelete(Jellyfin.Database.Implementations.Entities.User,System.Collections.Generic.List`1<MediaBrowser.Controller.Entities.Folder>)
CanDelete(Jellyfin.Database.Implementations.Entities.User)
CanDownload()
IsAuthorizedToDownload(Jellyfin.Database.Implementations.Entities.User)
CanDownload(Jellyfin.Database.Implementations.Entities.User)
ToString()
GetInternalMetadataPath()
GetInternalMetadataPath(System.String)
CreateSortName()
ModifySortChunks(System.ReadOnlySpan`1<System.Char>)
GetParent()
FindParent()
GetPlayAccess(Jellyfin.Database.Implementations.Entities.User)
GetMediaStreams()
IsActiveRecording()
GetMediaSources(System.Boolean)
GetAllItemsForMediaSources()
GetVersionInfo(System.Boolean,MediaBrowser.Controller.Entities.BaseItem,MediaBrowser.Model.Dto.MediaSourceType)
GetMediaSourceName(MediaBrowser.Controller.Entities.BaseItem)
RefreshMetadata(System.Threading.CancellationToken)
IsVisibleStandaloneInternal(Jellyfin.Database.Implementations.Entities.User,System.Boolean)
SetParent(MediaBrowser.Controller.Entities.Folder)
GetFileSystemChildren(MediaBrowser.Controller.Providers.IDirectoryService)
GetPresentationUniqueKey()
RequiresRefresh()
GetUserDataKeys()
UpdateFromResolvedItem(MediaBrowser.Controller.Entities.BaseItem)
AfterMetadataRefresh()
GetPreferredMetadataLanguage()
GetPreferredMetadataCountryCode()
IsSaveLocalMetadataEnabled()
IsParentalAllowed(Jellyfin.Database.Implementations.Entities.User,System.Boolean)
GetParentalRatingScore()
GetInheritedTags()
IsVisibleViaTags(Jellyfin.Database.Implementations.Entities.User,System.Boolean)
GetBlockUnratedType()
GetBlockUnratedValue(Jellyfin.Database.Implementations.Entities.User)
IsVisible(Jellyfin.Database.Implementations.Entities.User,System.Boolean)
IsVisibleStandalone(Jellyfin.Database.Implementations.Entities.User)
GetClientTypeName()
GetBaseItemKind()
GetLinkedChild(MediaBrowser.Controller.Entities.LinkedChild)
FindLinkedChild(MediaBrowser.Controller.Entities.LinkedChild)
AddStudio(System.String)
SetStudios(System.Collections.Generic.IEnumerable`1<System.String>)
AddGenre(System.String)
MarkPlayed(Jellyfin.Database.Implementations.Entities.User,System.Nullable`1<System.DateTime>,System.Boolean)
MarkUnplayed(Jellyfin.Database.Implementations.Entities.User)
ChangedExternally()
HasImage(MediaBrowser.Model.Entities.ImageType,System.Int32)
SetImage(MediaBrowser.Controller.Entities.ItemImageInfo,System.Int32)
SetImagePath(MediaBrowser.Model.Entities.ImageType,System.Int32,MediaBrowser.Model.IO.FileSystemMetadata)
RemoveImage(MediaBrowser.Controller.Entities.ItemImageInfo)
RemoveImages(System.Collections.Generic.IEnumerable`1<MediaBrowser.Controller.Entities.ItemImageInfo>)
AddImage(MediaBrowser.Controller.Entities.ItemImageInfo)
ValidateImages()
GetImagePath(MediaBrowser.Model.Entities.ImageType,System.Int32)
GetImageInfo(MediaBrowser.Model.Entities.ImageType,System.Int32)
GetImageIndex(MediaBrowser.Controller.Entities.ItemImageInfo)
AddImages(MediaBrowser.Model.Entities.ImageType,System.Collections.Generic.List`1<MediaBrowser.Model.IO.FileSystemMetadata>)
GetImageInfo(MediaBrowser.Model.IO.FileSystemMetadata,MediaBrowser.Model.Entities.ImageType)
GetDeletePaths()
GetLocalMetadataFilesToDelete()
AllowsMultipleImages(MediaBrowser.Model.Entities.ImageType)
SwapImagesAsync(MediaBrowser.Model.Entities.ImageType,System.Int32,System.Int32)
IsPlayed(Jellyfin.Database.Implementations.Entities.User,MediaBrowser.Controller.Entities.UserItemData)
IsFavoriteOrLiked(Jellyfin.Database.Implementations.Entities.User,MediaBrowser.Controller.Entities.UserItemData)
IsUnplayed(Jellyfin.Database.Implementations.Entities.User,MediaBrowser.Controller.Entities.UserItemData)
MediaBrowser.Controller.Providers.IHasLookupInfo<MediaBrowser.Controller.Providers.ItemLookupInfo>.GetLookupInfo()
GetItemLookupInfo()
GetNameForMetadataLookup()
BeforeMetadataRefresh(System.Boolean)
GetMappedPath(MediaBrowser.Controller.Entities.BaseItem,System.String,System.Nullable`1<MediaBrowser.Model.MediaInfo.MediaProtocol>)
FillUserDataDtoValues(MediaBrowser.Model.Dto.UserItemDataDto,MediaBrowser.Controller.Entities.UserItemData,MediaBrowser.Model.Dto.BaseItemDto,Jellyfin.Database.Implementations.Entities.User,MediaBrowser.Controller.Dto.DtoOptions)
GetEtag(Jellyfin.Database.Implementations.Entities.User)
GetEtagValues(Jellyfin.Database.Implementations.Entities.User)
GetAncestorIds()
GetTopParent()
GetIdsForAncestorQuery()
GetRefreshProgress()
OnMetadataChanged()
UpdateRatingToItems(System.Collections.Generic.IReadOnlyList`1<MediaBrowser.Controller.Entities.BaseItem>)
GetThemeSongs(Jellyfin.Database.Implementations.Entities.User)
GetThemeSongs(Jellyfin.Database.Implementations.Entities.User,System.Collections.Generic.IEnumerable`1<System.ValueTuple`2<Jellyfin.Data.Enums.ItemSortBy,Jellyfin.Database.Implementations.Enums.SortOrder>>)
GetThemeVideos(Jellyfin.Database.Implementations.Entities.User)
GetThemeVideos(Jellyfin.Database.Implementations.Entities.User,System.Collections.Generic.IEnumerable`1<System.ValueTuple`2<Jellyfin.Data.Enums.ItemSortBy,Jellyfin.Database.Implementations.Enums.SortOrder>>)
GetExtras()
GetExtras(System.Collections.Generic.IReadOnlyCollection`1<MediaBrowser.Model.Entities.ExtraType>)
GetRunTimeTicksForPlayState()
Equals(System.Object)
Equals(MediaBrowser.Controller.Entities.BaseItem)
GetHashCode()