< 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: 373
Uncovered lines: 353
Coverable lines: 726
Total lines: 2667
Line coverage: 51.3%
Branch coverage
41%
Covered branches: 186
Total branches: 448
Branch coverage: 41.5%
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()75%4485.71%
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%
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%620%
IsFavoriteOrLiked(...)0%2040%
IsUnplayed(...)0%620%
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        {
 975101            Tags = Array.Empty<string>();
 975102            Genres = Array.Empty<string>();
 975103            Studios = Array.Empty<string>();
 975104            ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 975105            LockedFields = Array.Empty<MetadataField>();
 975106            ImageInfos = Array.Empty<ItemImageInfo>();
 975107            ProductionLocations = Array.Empty<string>();
 975108            RemoteTrailers = Array.Empty<MediaUrl>();
 975109            ExtraIds = Array.Empty<Guid>();
 975110        }
 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]
 16163        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        {
 944188            get => _name;
 189            set
 190            {
 355191                _name = value;
 192
 193                // lazy load this again
 355194                _sortName = null;
 355195            }
 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            {
 1842257                if (!ChannelId.IsEmpty())
 258                {
 0259                    return SourceType.Channel;
 260                }
 261
 1842262                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            {
 340275                if (IsFolder)
 276                {
 289277                    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            {
 2358335                var path = Path;
 336
 2358337                if (string.IsNullOrEmpty(path))
 338                {
 116339                    return null;
 340                }
 341
 2242342                return MediaSourceManager.GetPathProtocol(path);
 343            }
 344        }
 345
 346        [JsonIgnore]
 2337347        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            {
 1242357                if (SourceType == SourceType.Channel)
 358                {
 0359                    return false;
 360                }
 361
 1242362                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]
 100381        public virtual bool EnableAlphaNumericSorting => true;
 382
 103383        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]
 94439        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        {
 436506            get => _forcedSortName;
 507            set
 508            {
 102509                _forcedSortName = value;
 102510                _sortName = null;
 102511            }
 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            {
 134523                if (_sortName is null)
 524                {
 100525                    if (!string.IsNullOrEmpty(ForcedSortName))
 526                    {
 527                        // Need the ToLower because that's what CreateSortName does
 0528                        _sortName = ModifySortChunks(ForcedSortName).ToLowerInvariant();
 529                    }
 530                    else
 531                    {
 100532                        _sortName = CreateSortName();
 533                    }
 534                }
 535
 134536                return _sortName;
 537            }
 538
 131539            set => _sortName = value;
 540        }
 541
 542        [JsonIgnore]
 334543        public virtual Guid DisplayParentId => ParentId;
 544
 545        [JsonIgnore]
 546        public BaseItem DisplayParent
 547        {
 548            get
 549            {
 328550                var id = DisplayParentId;
 328551                if (id.IsEmpty())
 552                {
 238553                    return null;
 554                }
 555
 90556                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            {
 164683                var officialRating = OfficialRating;
 164684                if (!string.IsNullOrEmpty(officialRating))
 685                {
 0686                    return officialRating;
 687                }
 688
 164689                var parent = DisplayParent;
 164690                if (parent is not null)
 691                {
 45692                    return parent.OfficialRatingForComparison;
 693                }
 694
 119695                return null;
 696            }
 697        }
 698
 699        [JsonIgnore]
 700        public string CustomRatingForComparison
 701        {
 702            get
 703            {
 164704                var customRating = CustomRating;
 164705                if (!string.IsNullOrEmpty(customRating))
 706                {
 0707                    return customRating;
 708                }
 709
 164710                var parent = DisplayParent;
 164711                if (parent is not null)
 712                {
 45713                    return parent.CustomRatingForComparison;
 714                }
 715
 119716                return null;
 717            }
 718        }
 719
 720        /// <summary>
 721        /// Gets or sets the provider ids.
 722        /// </summary>
 723        /// <value>The provider ids.</value>
 724        [JsonIgnore]
 725        public Dictionary<string, string> ProviderIds { get; set; }
 726
 727        [JsonIgnore]
 0728        public virtual Folder LatestItemsIndexContainer => null;
 729
 730        [JsonIgnore]
 731        public string PresentationUniqueKey { get; set; }
 732
 733        [JsonIgnore]
 0734        public virtual bool EnableRememberingTrackSelections => true;
 735
 736        [JsonIgnore]
 737        public virtual bool IsTopParent
 738        {
 739            get
 740            {
 220741                if (this is BasePluginFolder || this is Channel)
 742                {
 45743                    return true;
 744                }
 745
 175746                if (this is IHasCollectionType view)
 747                {
 19748                    if (view.CollectionType == CollectionType.livetv)
 749                    {
 0750                        return true;
 751                    }
 752                }
 753
 175754                if (GetParent() is AggregateFolder)
 755                {
 0756                    return true;
 757                }
 758
 175759                return false;
 760            }
 761        }
 762
 763        [JsonIgnore]
 170764        public virtual bool SupportsAncestors => true;
 765
 766        [JsonIgnore]
 86767        protected virtual bool SupportsOwnedItems => !ParentId.IsEmpty() && IsFileProtocol;
 768
 769        [JsonIgnore]
 60770        public virtual bool SupportsPeople => false;
 771
 772        [JsonIgnore]
 0773        public virtual bool SupportsThemeMedia => false;
 774
 775        [JsonIgnore]
 0776        public virtual bool SupportsInheritedParentImages => false;
 777
 778        /// <summary>
 779        /// Gets a value indicating whether this instance is folder.
 780        /// </summary>
 781        /// <value><c>true</c> if this instance is folder; otherwise, <c>false</c>.</value>
 782        [JsonIgnore]
 71783        public virtual bool IsFolder => false;
 784
 785        [JsonIgnore]
 0786        public virtual bool IsDisplayedAsFolder => false;
 787
 788        /// <summary>
 789        /// Gets or sets the remote trailers.
 790        /// </summary>
 791        /// <value>The remote trailers.</value>
 792        public IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
 793
 794        public virtual double GetDefaultPrimaryImageAspectRatio()
 795        {
 0796            return 0;
 797        }
 798
 799        public virtual string CreatePresentationUniqueKey()
 800        {
 53801            return Id.ToString("N", CultureInfo.InvariantCulture);
 802        }
 803
 804        public virtual bool CanDelete()
 805        {
 0806            if (SourceType == SourceType.Channel)
 807            {
 0808                return ChannelManager.CanDelete(this);
 809            }
 810
 0811            return IsFileProtocol;
 812        }
 813
 814        public virtual bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
 815        {
 0816            if (user.HasPermission(PermissionKind.EnableContentDeletion))
 817            {
 0818                return true;
 819            }
 820
 0821            var allowed = user.GetPreferenceValues<Guid>(PreferenceKind.EnableContentDeletionFromFolders);
 822
 0823            if (SourceType == SourceType.Channel)
 824            {
 0825                return allowed.Contains(ChannelId);
 826            }
 827
 0828            var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
 829
 0830            foreach (var folder in collectionFolders)
 831            {
 0832                if (allowed.Contains(folder.Id))
 833                {
 0834                    return true;
 835                }
 836            }
 837
 0838            return false;
 0839        }
 840
 841        public BaseItem GetOwner()
 842        {
 614843            var ownerId = OwnerId;
 614844            return ownerId.IsEmpty() ? null : LibraryManager.GetItemById(ownerId);
 845        }
 846
 847        public bool CanDelete(User user, List<Folder> allCollectionFolders)
 848        {
 6849            return CanDelete() && IsAuthorizedToDelete(user, allCollectionFolders);
 850        }
 851
 852        public virtual bool CanDelete(User user)
 853        {
 6854            var allCollectionFolders = LibraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
 855
 6856            return CanDelete(user, allCollectionFolders);
 857        }
 858
 859        public virtual bool CanDownload()
 860        {
 6861            return false;
 862        }
 863
 864        public virtual bool IsAuthorizedToDownload(User user)
 865        {
 0866            return user.HasPermission(PermissionKind.EnableContentDownloading);
 867        }
 868
 869        public bool CanDownload(User user)
 870        {
 6871            return CanDownload() && IsAuthorizedToDownload(user);
 872        }
 873
 874        /// <inheritdoc />
 875        public override string ToString()
 876        {
 69877            return Name;
 878        }
 879
 880        public virtual string GetInternalMetadataPath()
 881        {
 67882            var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath;
 883
 67884            return GetInternalMetadataPath(basePath);
 885        }
 886
 887        protected virtual string GetInternalMetadataPath(string basePath)
 888        {
 67889            if (SourceType == SourceType.Channel)
 890            {
 0891                return System.IO.Path.Join(basePath, "channels", ChannelId.ToString("N", CultureInfo.InvariantCulture), 
 892            }
 893
 67894            ReadOnlySpan<char> idString = Id.ToString("N", CultureInfo.InvariantCulture);
 895
 67896            return System.IO.Path.Join(basePath, "library", idString[..2], idString);
 897        }
 898
 899        /// <summary>
 900        /// Creates the name of the sort.
 901        /// </summary>
 902        /// <returns>System.String.</returns>
 903        protected virtual string CreateSortName()
 904        {
 100905            if (Name is null)
 906            {
 0907                return null; // some items may not have name filled in properly
 908            }
 909
 100910            if (!EnableAlphaNumericSorting)
 911            {
 0912                return Name.TrimStart();
 913            }
 914
 100915            var sortable = Name.Trim().ToLowerInvariant();
 916
 800917            foreach (var search in ConfigurationManager.Configuration.SortRemoveWords)
 918            {
 919                // Remove from beginning if a space follows
 300920                if (sortable.StartsWith(search + " ", StringComparison.Ordinal))
 921                {
 0922                    sortable = sortable.Remove(0, search.Length + 1);
 923                }
 924
 925                // Remove from middle if surrounded by spaces
 300926                sortable = sortable.Replace(" " + search + " ", " ", StringComparison.Ordinal);
 927
 928                // Remove from end if preceeded by a space
 300929                if (sortable.EndsWith(" " + search, StringComparison.Ordinal))
 930                {
 0931                    sortable = sortable.Remove(sortable.Length - (search.Length + 1));
 932                }
 933            }
 934
 1400935            foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters)
 936            {
 600937                sortable = sortable.Replace(removeChar, string.Empty, StringComparison.Ordinal);
 938            }
 939
 800940            foreach (var replaceChar in ConfigurationManager.Configuration.SortReplaceCharacters)
 941            {
 300942                sortable = sortable.Replace(replaceChar, " ", StringComparison.Ordinal);
 943            }
 944
 100945            return ModifySortChunks(sortable);
 946        }
 947
 948        internal static string ModifySortChunks(ReadOnlySpan<char> name)
 949        {
 950            static void AppendChunk(StringBuilder builder, bool isDigitChunk, ReadOnlySpan<char> chunk)
 951            {
 952                if (isDigitChunk && chunk.Length < 10)
 953                {
 954                    builder.Append('0', 10 - chunk.Length);
 955                }
 956
 957                builder.Append(chunk);
 958            }
 959
 106960            if (name.IsEmpty)
 961            {
 1962                return string.Empty;
 963            }
 964
 105965            var builder = new StringBuilder(name.Length);
 966
 105967            int chunkStart = 0;
 105968            bool isDigitChunk = char.IsDigit(name[0]);
 1606969            for (int i = 0; i < name.Length; i++)
 970            {
 698971                var isDigit = char.IsDigit(name[i]);
 698972                if (isDigit != isDigitChunk)
 973                {
 7974                    AppendChunk(builder, isDigitChunk, name.Slice(chunkStart, i - chunkStart));
 7975                    chunkStart = i;
 7976                    isDigitChunk = isDigit;
 977                }
 978            }
 979
 105980            AppendChunk(builder, isDigitChunk, name.Slice(chunkStart));
 981
 982            // logger.LogDebug("ModifySortChunks Start: {0} End: {1}", name, builder.ToString());
 105983            var result = builder.ToString().RemoveDiacritics();
 105984            if (!result.All(char.IsAscii))
 985            {
 0986                result = result.Transliterated();
 987            }
 988
 105989            return result;
 990        }
 991
 992        public BaseItem GetParent()
 993        {
 1563994            var parentId = ParentId;
 1563995            if (parentId.IsEmpty())
 996            {
 1205997                return null;
 998            }
 999
 3581000            return LibraryManager.GetItemById(parentId);
 1001        }
 1002
 1003        public IEnumerable<BaseItem> GetParents()
 1004        {
 1005            var parent = GetParent();
 1006
 1007            while (parent is not null)
 1008            {
 1009                yield return parent;
 1010
 1011                parent = parent.GetParent();
 1012            }
 1013        }
 1014
 1015        /// <summary>
 1016        /// Finds a parent of a given type.
 1017        /// </summary>
 1018        /// <typeparam name="T">Type of parent.</typeparam>
 1019        /// <returns>``0.</returns>
 1020        public T FindParent<T>()
 1021            where T : Folder
 1022        {
 01023            foreach (var parent in GetParents())
 1024            {
 01025                if (parent is T item)
 1026                {
 01027                    return item;
 1028                }
 1029            }
 1030
 01031            return null;
 01032        }
 1033
 1034        /// <summary>
 1035        /// Gets the play access.
 1036        /// </summary>
 1037        /// <param name="user">The user.</param>
 1038        /// <returns>PlayAccess.</returns>
 1039        public PlayAccess GetPlayAccess(User user)
 1040        {
 61041            if (!user.HasPermission(PermissionKind.EnableMediaPlayback))
 1042            {
 01043                return PlayAccess.None;
 1044            }
 1045
 1046            // if (!user.IsParentalScheduleAllowed())
 1047            // {
 1048            //    return PlayAccess.None;
 1049            // }
 1050
 61051            return PlayAccess.Full;
 1052        }
 1053
 1054        public virtual IReadOnlyList<MediaStream> GetMediaStreams()
 1055        {
 01056            return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
 01057            {
 01058                ItemId = Id
 01059            });
 1060        }
 1061
 1062        protected virtual bool IsActiveRecording()
 1063        {
 01064            return false;
 1065        }
 1066
 1067        public virtual IReadOnlyList<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
 1068        {
 01069            if (SourceType == SourceType.Channel)
 1070            {
 01071                var sources = ChannelManager.GetStaticMediaSources(this, CancellationToken.None)
 01072                           .ToList();
 1073
 01074                if (sources.Count > 0)
 1075                {
 01076                    return sources;
 1077                }
 1078            }
 1079
 01080            var list = GetAllItemsForMediaSources();
 01081            var result = list.Select(i => GetVersionInfo(enablePathSubstitution, i.Item, i.MediaSourceType)).ToList();
 1082
 01083            if (IsActiveRecording())
 1084            {
 01085                foreach (var mediaSource in result)
 1086                {
 01087                    mediaSource.Type = MediaSourceType.Placeholder;
 1088                }
 1089            }
 1090
 01091            return result.OrderBy(i =>
 01092            {
 01093                if (i.VideoType == VideoType.VideoFile)
 01094                {
 01095                    return 0;
 01096                }
 01097
 01098                return 1;
 01099            }).ThenBy(i => i.Video3DFormat.HasValue ? 1 : 0)
 01100            .ThenByDescending(i => i, new MediaSourceWidthComparator())
 01101            .ToArray();
 1102        }
 1103
 1104        protected virtual IEnumerable<(BaseItem Item, MediaSourceType MediaSourceType)> GetAllItemsForMediaSources()
 1105        {
 01106            return Enumerable.Empty<(BaseItem, MediaSourceType)>();
 1107        }
 1108
 1109        private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type)
 1110        {
 01111            ArgumentNullException.ThrowIfNull(item);
 1112
 01113            var protocol = item.PathProtocol;
 1114
 01115            var info = new MediaSourceInfo
 01116            {
 01117                Id = item.Id.ToString("N", CultureInfo.InvariantCulture),
 01118                Protocol = protocol ?? MediaProtocol.File,
 01119                MediaStreams = MediaSourceManager.GetMediaStreams(item.Id),
 01120                MediaAttachments = MediaSourceManager.GetMediaAttachments(item.Id),
 01121                Name = GetMediaSourceName(item),
 01122                Path = enablePathSubstitution ? GetMappedPath(item, item.Path, protocol) : item.Path,
 01123                RunTimeTicks = item.RunTimeTicks,
 01124                Container = item.Container,
 01125                Size = item.Size,
 01126                Type = type,
 01127                HasSegments = MediaSegmentManager.IsTypeSupported(item)
 01128                    && (protocol is null or MediaProtocol.File)
 01129                    && MediaSegmentManager.HasSegments(item.Id)
 01130            };
 1131
 01132            if (string.IsNullOrEmpty(info.Path))
 1133            {
 01134                info.Type = MediaSourceType.Placeholder;
 1135            }
 1136
 01137            if (info.Protocol == MediaProtocol.File)
 1138            {
 01139                info.ETag = item.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N", Cultur
 1140            }
 1141
 01142            var video = item as Video;
 01143            if (video is not null)
 1144            {
 01145                info.IsoType = video.IsoType;
 01146                info.VideoType = video.VideoType;
 01147                info.Video3DFormat = video.Video3DFormat;
 01148                info.Timestamp = video.Timestamp;
 1149
 01150                if (video.IsShortcut)
 1151                {
 01152                    info.IsRemote = true;
 01153                    info.Path = video.ShortcutPath;
 01154                    info.Protocol = MediaSourceManager.GetPathProtocol(info.Path);
 1155                }
 1156
 01157                if (string.IsNullOrEmpty(info.Container))
 1158                {
 01159                    if (video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Iso)
 1160                    {
 01161                        if (protocol.HasValue && protocol.Value == MediaProtocol.File)
 1162                        {
 01163                            info.Container = System.IO.Path.GetExtension(item.Path).TrimStart('.');
 1164                        }
 1165                    }
 1166                }
 1167            }
 1168
 01169            if (string.IsNullOrEmpty(info.Container))
 1170            {
 01171                if (protocol.HasValue && protocol.Value == MediaProtocol.File)
 1172                {
 01173                    info.Container = System.IO.Path.GetExtension(item.Path).TrimStart('.');
 1174                }
 1175            }
 1176
 01177            if (info.SupportsDirectStream && !string.IsNullOrEmpty(info.Path))
 1178            {
 01179                info.SupportsDirectStream = MediaSourceManager.SupportsDirectStream(info.Path, info.Protocol);
 1180            }
 1181
 01182            if (video is not null && video.VideoType != VideoType.VideoFile)
 1183            {
 01184                info.SupportsDirectStream = false;
 1185            }
 1186
 01187            info.Bitrate = item.TotalBitrate;
 01188            info.InferTotalBitrate();
 1189
 01190            return info;
 1191        }
 1192
 1193        internal string GetMediaSourceName(BaseItem item)
 1194        {
 41195            var terms = new List<string>();
 1196
 41197            var path = item.Path;
 41198            if (item.IsFileProtocol && !string.IsNullOrEmpty(path))
 1199            {
 41200                var displayName = System.IO.Path.GetFileNameWithoutExtension(path);
 41201                if (HasLocalAlternateVersions)
 1202                {
 41203                    var containingFolderName = System.IO.Path.GetFileName(ContainingFolderPath);
 41204                    if (displayName.Length > containingFolderName.Length && displayName.StartsWith(containingFolderName,
 1205                    {
 21206                        var name = displayName.AsSpan(containingFolderName.Length).TrimStart([' ', '-']);
 21207                        if (!name.IsWhiteSpace())
 1208                        {
 21209                            terms.Add(name.ToString());
 1210                        }
 1211                    }
 1212                }
 1213
 41214                if (terms.Count == 0)
 1215                {
 21216                    terms.Add(displayName);
 1217                }
 1218            }
 1219
 41220            if (terms.Count == 0)
 1221            {
 01222                terms.Add(item.Name);
 1223            }
 1224
 41225            if (item is Video video)
 1226            {
 41227                if (video.Video3DFormat.HasValue)
 1228                {
 01229                    terms.Add("3D");
 1230                }
 1231
 41232                if (video.VideoType == VideoType.BluRay)
 1233                {
 01234                    terms.Add("Bluray");
 1235                }
 41236                else if (video.VideoType == VideoType.Dvd)
 1237                {
 01238                    terms.Add("DVD");
 1239                }
 41240                else if (video.VideoType == VideoType.Iso)
 1241                {
 01242                    if (video.IsoType.HasValue)
 1243                    {
 01244                        if (video.IsoType.Value == IsoType.BluRay)
 1245                        {
 01246                            terms.Add("Bluray");
 1247                        }
 01248                        else if (video.IsoType.Value == IsoType.Dvd)
 1249                        {
 01250                            terms.Add("DVD");
 1251                        }
 1252                    }
 1253                    else
 1254                    {
 01255                        terms.Add("ISO");
 1256                    }
 1257                }
 1258            }
 1259
 41260            return string.Join('/', terms);
 1261        }
 1262
 1263        public Task RefreshMetadata(CancellationToken cancellationToken)
 1264        {
 451265            return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(FileSystem)), cancellationToken);
 1266        }
 1267
 1268        /// <summary>
 1269        /// The base implementation to refresh metadata.
 1270        /// </summary>
 1271        /// <param name="options">The options.</param>
 1272        /// <param name="cancellationToken">The cancellation token.</param>
 1273        /// <returns>true if a provider reports we changed.</returns>
 1274        public async Task<ItemUpdateType> RefreshMetadata(MetadataRefreshOptions options, CancellationToken cancellation
 1275        {
 1276            var requiresSave = false;
 1277
 1278            if (SupportsOwnedItems)
 1279            {
 1280                try
 1281                {
 1282                    if (IsFileProtocol)
 1283                    {
 1284                        requiresSave = await RefreshedOwnedItems(options, GetFileSystemChildren(options.DirectoryService
 1285                    }
 1286
 1287                    await LibraryManager.UpdateImagesAsync(this).ConfigureAwait(false); // ensure all image properties i
 1288                }
 1289                catch (Exception ex)
 1290                {
 1291                    Logger.LogError(ex, "Error refreshing owned items for {Path}", Path ?? Name);
 1292                }
 1293            }
 1294
 1295            var refreshOptions = requiresSave
 1296                ? new MetadataRefreshOptions(options)
 1297                {
 1298                    ForceSave = true
 1299                }
 1300                : options;
 1301
 1302            return await ProviderManager.RefreshSingleItem(this, refreshOptions, cancellationToken).ConfigureAwait(false
 1303        }
 1304
 1305        protected bool IsVisibleStandaloneInternal(User user, bool checkFolders)
 1306        {
 01307            if (!IsVisible(user))
 1308            {
 01309                return false;
 1310            }
 1311
 01312            if (GetParents().Any(i => !i.IsVisible(user, true)))
 1313            {
 01314                return false;
 1315            }
 1316
 01317            if (checkFolders)
 1318            {
 01319                var topParent = GetParents().LastOrDefault() ?? this;
 1320
 01321                if (string.IsNullOrEmpty(topParent.Path))
 1322                {
 01323                    return true;
 1324                }
 1325
 01326                var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList();
 1327
 01328                if (itemCollectionFolders.Count > 0)
 1329                {
 01330                    var userCollectionFolders = LibraryManager.GetUserRootFolder().GetChildren(user, true).Select(i => i
 01331                    if (!itemCollectionFolders.Any(userCollectionFolders.Contains))
 1332                    {
 01333                        return false;
 1334                    }
 1335                }
 1336            }
 1337
 01338            return true;
 1339        }
 1340
 1341        public void SetParent(Folder parent)
 1342        {
 151343            ParentId = parent is null ? Guid.Empty : parent.Id;
 151344        }
 1345
 1346        /// <summary>
 1347        /// Refreshes owned items such as trailers, theme videos, special features, etc.
 1348        /// Returns true or false indicating if changes were found.
 1349        /// </summary>
 1350        /// <param name="options">The metadata refresh options.</param>
 1351        /// <param name="fileSystemChildren">The list of filesystem children.</param>
 1352        /// <param name="cancellationToken">The cancellation token.</param>
 1353        /// <returns><c>true</c> if any items have changed, else <c>false</c>.</returns>
 1354        protected virtual async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, IReadOnlyList<FileSystemM
 1355        {
 1356            if (!IsFileProtocol || !SupportsOwnedItems || IsInMixedFolder || this is ICollectionFolder or UserRootFolder
 1357            {
 1358                return false;
 1359            }
 1360
 1361            return await RefreshExtras(this, options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
 1362        }
 1363
 1364        protected virtual FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService)
 1365        {
 291366            return directoryService.GetFileSystemEntries(ContainingFolderPath);
 1367        }
 1368
 1369        private async Task<bool> RefreshExtras(BaseItem item, MetadataRefreshOptions options, IReadOnlyList<FileSystemMe
 1370        {
 1371            var extras = LibraryManager.FindExtras(item, fileSystemChildren, options.DirectoryService).ToArray();
 1372            var newExtraIds = Array.ConvertAll(extras, x => x.Id);
 1373            var extrasChanged = !item.ExtraIds.SequenceEqual(newExtraIds);
 1374
 1375            if (!extrasChanged && !options.ReplaceAllMetadata && options.MetadataRefreshMode != MetadataRefreshMode.Full
 1376            {
 1377                return false;
 1378            }
 1379
 1380            var ownerId = item.Id;
 1381
 1382            var tasks = extras.Select(i =>
 1383            {
 1384                var subOptions = new MetadataRefreshOptions(options);
 1385                if (!i.OwnerId.Equals(ownerId) || !i.ParentId.IsEmpty())
 1386                {
 1387                    i.OwnerId = ownerId;
 1388                    i.ParentId = Guid.Empty;
 1389                    subOptions.ForceSave = true;
 1390                }
 1391
 1392                return RefreshMetadataForOwnedItem(i, true, subOptions, cancellationToken);
 1393            });
 1394
 1395            // Cleanup removed extras
 1396            var removedExtraIds = item.ExtraIds.Where(e => !newExtraIds.Contains(e)).ToArray();
 1397            if (removedExtraIds.Length > 0)
 1398            {
 1399                var removedExtras = LibraryManager.GetItemList(new InternalItemsQuery()
 1400                {
 1401                    ItemIds = removedExtraIds
 1402                });
 1403                foreach (var removedExtra in removedExtras)
 1404                {
 1405                    LibraryManager.DeleteItem(removedExtra, new DeleteOptions()
 1406                    {
 1407                        DeleteFileLocation = false
 1408                    });
 1409                }
 1410            }
 1411
 1412            await Task.WhenAll(tasks).ConfigureAwait(false);
 1413
 1414            item.ExtraIds = newExtraIds;
 1415
 1416            return true;
 1417        }
 1418
 1419        public string GetPresentationUniqueKey()
 1420        {
 01421            return PresentationUniqueKey ?? CreatePresentationUniqueKey();
 1422        }
 1423
 1424        public virtual bool RequiresRefresh()
 1425        {
 541426            if (string.IsNullOrEmpty(Path) || DateModified == DateTime.MinValue)
 1427            {
 01428                return false;
 1429            }
 1430
 541431            var info = FileSystem.GetFileSystemInfo(Path);
 1432
 541433            return info.Exists && this.HasChanged(info.LastWriteTimeUtc);
 1434        }
 1435
 1436        public virtual List<string> GetUserDataKeys()
 1437        {
 941438            var list = new List<string>();
 1439
 941440            if (SourceType == SourceType.Channel)
 1441            {
 01442                if (!string.IsNullOrEmpty(ExternalId))
 1443                {
 01444                    list.Add(ExternalId);
 1445                }
 1446            }
 1447
 941448            list.Add(Id.ToString());
 941449            return list;
 1450        }
 1451
 1452        internal virtual ItemUpdateType UpdateFromResolvedItem(BaseItem newItem)
 1453        {
 71454            var updateType = ItemUpdateType.None;
 1455
 71456            if (IsInMixedFolder != newItem.IsInMixedFolder)
 1457            {
 01458                IsInMixedFolder = newItem.IsInMixedFolder;
 01459                updateType |= ItemUpdateType.MetadataImport;
 1460            }
 1461
 71462            return updateType;
 1463        }
 1464
 1465        public void AfterMetadataRefresh()
 1466        {
 511467            _sortName = null;
 511468        }
 1469
 1470        /// <summary>
 1471        /// Gets the preferred metadata language.
 1472        /// </summary>
 1473        /// <returns>System.String.</returns>
 1474        public string GetPreferredMetadataLanguage()
 1475        {
 531476            string lang = PreferredMetadataLanguage;
 1477
 531478            if (string.IsNullOrEmpty(lang))
 1479            {
 531480                lang = GetParents()
 531481                    .Select(i => i.PreferredMetadataLanguage)
 531482                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1483            }
 1484
 531485            if (string.IsNullOrEmpty(lang))
 1486            {
 531487                lang = LibraryManager.GetCollectionFolders(this)
 531488                    .Select(i => i.PreferredMetadataLanguage)
 531489                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1490            }
 1491
 531492            if (string.IsNullOrEmpty(lang))
 1493            {
 531494                lang = LibraryManager.GetLibraryOptions(this).PreferredMetadataLanguage;
 1495            }
 1496
 531497            if (string.IsNullOrEmpty(lang))
 1498            {
 531499                lang = ConfigurationManager.Configuration.PreferredMetadataLanguage;
 1500            }
 1501
 531502            return lang;
 1503        }
 1504
 1505        /// <summary>
 1506        /// Gets the preferred metadata language.
 1507        /// </summary>
 1508        /// <returns>System.String.</returns>
 1509        public string GetPreferredMetadataCountryCode()
 1510        {
 531511            string lang = PreferredMetadataCountryCode;
 1512
 531513            if (string.IsNullOrEmpty(lang))
 1514            {
 531515                lang = GetParents()
 531516                    .Select(i => i.PreferredMetadataCountryCode)
 531517                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1518            }
 1519
 531520            if (string.IsNullOrEmpty(lang))
 1521            {
 531522                lang = LibraryManager.GetCollectionFolders(this)
 531523                    .Select(i => i.PreferredMetadataCountryCode)
 531524                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1525            }
 1526
 531527            if (string.IsNullOrEmpty(lang))
 1528            {
 531529                lang = LibraryManager.GetLibraryOptions(this).MetadataCountryCode;
 1530            }
 1531
 531532            if (string.IsNullOrEmpty(lang))
 1533            {
 531534                lang = ConfigurationManager.Configuration.MetadataCountryCode;
 1535            }
 1536
 531537            return lang;
 1538        }
 1539
 1540        public virtual bool IsSaveLocalMetadataEnabled()
 1541        {
 741542            if (SourceType == SourceType.Channel)
 1543            {
 01544                return false;
 1545            }
 1546
 741547            var libraryOptions = LibraryManager.GetLibraryOptions(this);
 1548
 741549            return libraryOptions.SaveLocalMetadata;
 1550        }
 1551
 1552        /// <summary>
 1553        /// Determines if a given user has access to this item.
 1554        /// </summary>
 1555        /// <param name="user">The user.</param>
 1556        /// <param name="skipAllowedTagsCheck">Don't check for allowed tags.</param>
 1557        /// <returns><c>true</c> if [is parental allowed] [the specified user]; otherwise, <c>false</c>.</returns>
 1558        /// <exception cref="ArgumentNullException">If user is null.</exception>
 1559        public bool IsParentalAllowed(User user, bool skipAllowedTagsCheck)
 1560        {
 131561            ArgumentNullException.ThrowIfNull(user);
 1562
 131563            if (!IsVisibleViaTags(user, skipAllowedTagsCheck))
 1564            {
 01565                return false;
 1566            }
 1567
 131568            var maxAllowedRating = user.MaxParentalRatingScore;
 131569            var maxAllowedSubRating = user.MaxParentalRatingSubScore;
 131570            var rating = CustomRatingForComparison;
 1571
 131572            if (string.IsNullOrEmpty(rating))
 1573            {
 131574                rating = OfficialRatingForComparison;
 1575            }
 1576
 131577            if (string.IsNullOrEmpty(rating))
 1578            {
 131579                Logger.LogDebug("{0} has no parental rating set.", Name);
 131580                return !GetBlockUnratedValue(user);
 1581            }
 1582
 01583            var ratingScore = LocalizationManager.GetRatingScore(rating);
 1584
 1585            // Could not determine rating level
 01586            if (ratingScore is null)
 1587            {
 01588                var isAllowed = !GetBlockUnratedValue(user);
 1589
 01590                if (!isAllowed)
 1591                {
 01592                    Logger.LogDebug("{0} has an unrecognized parental rating of {1}.", Name, rating);
 1593                }
 1594
 01595                return isAllowed;
 1596            }
 1597
 01598            if (maxAllowedSubRating is not null)
 1599            {
 01600                return (ratingScore.SubScore ?? 0) <= maxAllowedSubRating && ratingScore.Score <= maxAllowedRating.Value
 1601            }
 1602
 01603            return !maxAllowedRating.HasValue || ratingScore.Score <= maxAllowedRating.Value;
 1604        }
 1605
 1606        public ParentalRatingScore GetParentalRatingScore()
 1607        {
 1061608            var rating = CustomRatingForComparison;
 1609
 1061610            if (string.IsNullOrEmpty(rating))
 1611            {
 1061612                rating = OfficialRatingForComparison;
 1613            }
 1614
 1061615            if (string.IsNullOrEmpty(rating))
 1616            {
 1061617                return null;
 1618            }
 1619
 01620            return LocalizationManager.GetRatingScore(rating);
 1621        }
 1622
 1623        public List<string> GetInheritedTags()
 1624        {
 981625            var list = new List<string>();
 981626            list.AddRange(Tags);
 1627
 2421628            foreach (var parent in GetParents())
 1629            {
 231630                list.AddRange(parent.Tags);
 1631            }
 1632
 1961633            foreach (var folder in LibraryManager.GetCollectionFolders(this))
 1634            {
 01635                list.AddRange(folder.Tags);
 1636            }
 1637
 981638            return list.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
 1639        }
 1640
 1641        private bool IsVisibleViaTags(User user, bool skipAllowedTagsCheck)
 1642        {
 131643            var allTags = GetInheritedTags();
 131644            if (user.GetPreference(PreferenceKind.BlockedTags).Any(i => allTags.Contains(i, StringComparison.OrdinalIgno
 1645            {
 01646                return false;
 1647            }
 1648
 131649            var parent = GetParents().FirstOrDefault() ?? this;
 131650            if (parent is UserRootFolder or AggregateFolder or UserView)
 1651            {
 131652                return true;
 1653            }
 1654
 01655            var allowedTagsPreference = user.GetPreference(PreferenceKind.AllowedTags);
 01656            if (!skipAllowedTagsCheck && allowedTagsPreference.Length != 0 && !allowedTagsPreference.Any(i => allTags.Co
 1657            {
 01658                return false;
 1659            }
 1660
 01661            return true;
 1662        }
 1663
 1664        public virtual UnratedItem GetBlockUnratedType()
 1665        {
 851666            if (SourceType == SourceType.Channel)
 1667            {
 01668                return UnratedItem.ChannelContent;
 1669            }
 1670
 851671            return UnratedItem.Other;
 1672        }
 1673
 1674        /// <summary>
 1675        /// Gets a bool indicating if access to the unrated item is blocked or not.
 1676        /// </summary>
 1677        /// <param name="user">The configuration.</param>
 1678        /// <returns><c>true</c> if blocked, <c>false</c> otherwise.</returns>
 1679        protected virtual bool GetBlockUnratedValue(User user)
 1680        {
 1681            // Don't block plain folders that are unrated. Let the media underneath get blocked
 1682            // Special folders like series and albums will override this method.
 131683            if (IsFolder || this is IItemByName)
 1684            {
 131685                return false;
 1686            }
 1687
 01688            return user.GetPreferenceValues<UnratedItem>(PreferenceKind.BlockUnratedItems).Contains(GetBlockUnratedType(
 1689        }
 1690
 1691        /// <summary>
 1692        /// Determines if this folder should be visible to a given user.
 1693        /// Default is just parental allowed. Can be overridden for more functionality.
 1694        /// </summary>
 1695        /// <param name="user">The user.</param>
 1696        /// <param name="skipAllowedTagsCheck">Don't check for allowed tags.</param>
 1697        /// <returns><c>true</c> if the specified user is visible; otherwise, <c>false</c>.</returns>
 1698        /// <exception cref="ArgumentNullException"><paramref name="user" /> is <c>null</c>.</exception>
 1699        public virtual bool IsVisible(User user, bool skipAllowedTagsCheck = false)
 1700        {
 131701            ArgumentNullException.ThrowIfNull(user);
 1702
 131703            return IsParentalAllowed(user, skipAllowedTagsCheck);
 1704        }
 1705
 1706        public virtual bool IsVisibleStandalone(User user)
 1707        {
 01708            if (SourceType == SourceType.Channel)
 1709            {
 01710                return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
 1711            }
 1712
 01713            return IsVisibleStandaloneInternal(user, true);
 1714        }
 1715
 1716        public virtual string GetClientTypeName()
 1717        {
 791718            if (IsFolder && SourceType == SourceType.Channel && this is not Channel && this is not Season && this is not
 1719            {
 01720                return "ChannelFolderItem";
 1721            }
 1722
 791723            return GetType().Name;
 1724        }
 1725
 1726        public BaseItemKind GetBaseItemKind()
 1727        {
 2321728            return _baseItemKind ??= Enum.Parse<BaseItemKind>(GetClientTypeName());
 1729        }
 1730
 1731        /// <summary>
 1732        /// Gets the linked child.
 1733        /// </summary>
 1734        /// <param name="info">The info.</param>
 1735        /// <returns>BaseItem.</returns>
 1736        protected BaseItem GetLinkedChild(LinkedChild info)
 1737        {
 1738            // First get using the cached Id
 01739            if (info.ItemId.HasValue)
 1740            {
 01741                if (info.ItemId.Value.IsEmpty())
 1742                {
 01743                    return null;
 1744                }
 1745
 01746                var itemById = LibraryManager.GetItemById(info.ItemId.Value);
 1747
 01748                if (itemById is not null)
 1749                {
 01750                    return itemById;
 1751                }
 1752            }
 1753
 01754            var item = FindLinkedChild(info);
 1755
 1756            // If still null, log
 01757            if (item is null)
 1758            {
 1759                // Don't keep searching over and over
 01760                info.ItemId = Guid.Empty;
 1761            }
 1762            else
 1763            {
 1764                // Cache the id for next time
 01765                info.ItemId = item.Id;
 1766            }
 1767
 01768            return item;
 1769        }
 1770
 1771        private BaseItem FindLinkedChild(LinkedChild info)
 1772        {
 01773            var path = info.Path;
 1774
 01775            if (!string.IsNullOrEmpty(path))
 1776            {
 01777                path = FileSystem.MakeAbsolutePath(ContainingFolderPath, path);
 1778
 01779                var itemByPath = LibraryManager.FindByPath(path, null);
 1780
 01781                if (itemByPath is null)
 1782                {
 01783                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1784                }
 1785
 01786                return itemByPath;
 1787            }
 1788
 01789            if (!string.IsNullOrEmpty(info.LibraryItemId))
 1790            {
 01791                var item = LibraryManager.GetItemById(info.LibraryItemId);
 1792
 01793                if (item is null)
 1794                {
 01795                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1796                }
 1797
 01798                return item;
 1799            }
 1800
 01801            return null;
 1802        }
 1803
 1804        /// <summary>
 1805        /// Adds a studio to the item.
 1806        /// </summary>
 1807        /// <param name="name">The name.</param>
 1808        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1809        public void AddStudio(string name)
 1810        {
 41811            ArgumentException.ThrowIfNullOrEmpty(name);
 41812            var current = Studios;
 1813
 41814            if (!current.Contains(name, StringComparison.OrdinalIgnoreCase))
 1815            {
 41816                int curLen = current.Length;
 41817                if (curLen == 0)
 1818                {
 41819                    Studios = [name];
 1820                }
 1821                else
 1822                {
 01823                    Studios = [.. current, name];
 1824                }
 1825            }
 01826        }
 1827
 1828        public void SetStudios(IEnumerable<string> names)
 1829        {
 01830            Studios = names.Trimmed().Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
 01831        }
 1832
 1833        /// <summary>
 1834        /// Adds a genre to the item.
 1835        /// </summary>
 1836        /// <param name="name">The name.</param>
 1837        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1838        public void AddGenre(string name)
 1839        {
 131840            ArgumentException.ThrowIfNullOrEmpty(name);
 1841
 131842            var genres = Genres;
 131843            if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))
 1844            {
 131845                Genres = [.. genres, name];
 1846            }
 131847        }
 1848
 1849        /// <summary>
 1850        /// Marks the played.
 1851        /// </summary>
 1852        /// <param name="user">The user.</param>
 1853        /// <param name="datePlayed">The date played.</param>
 1854        /// <param name="resetPosition">if set to <c>true</c> [reset position].</param>
 1855        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1856        public virtual void MarkPlayed(
 1857            User user,
 1858            DateTime? datePlayed,
 1859            bool resetPosition)
 1860        {
 01861            ArgumentNullException.ThrowIfNull(user);
 1862
 01863            var data = UserDataManager.GetUserData(user, this) ?? new UserItemData()
 01864            {
 01865                Key = GetUserDataKeys().First(),
 01866            };
 1867
 01868            if (datePlayed.HasValue)
 1869            {
 1870                // Increment
 01871                data.PlayCount++;
 1872            }
 1873
 1874            // Ensure it's at least one
 01875            data.PlayCount = Math.Max(data.PlayCount, 1);
 1876
 01877            if (resetPosition)
 1878            {
 01879                data.PlaybackPositionTicks = 0;
 1880            }
 1881
 01882            data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
 01883            data.Played = true;
 1884
 01885            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01886        }
 1887
 1888        /// <summary>
 1889        /// Marks the unplayed.
 1890        /// </summary>
 1891        /// <param name="user">The user.</param>
 1892        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1893        public virtual void MarkUnplayed(User user)
 1894        {
 01895            ArgumentNullException.ThrowIfNull(user);
 1896
 01897            var data = UserDataManager.GetUserData(user, this);
 1898
 1899            // I think it is okay to do this here.
 1900            // if this is only called when a user is manually forcing something to un-played
 1901            // then it probably is what we want to do...
 01902            data.PlayCount = 0;
 01903            data.PlaybackPositionTicks = 0;
 01904            data.LastPlayedDate = null;
 01905            data.Played = false;
 1906
 01907            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01908        }
 1909
 1910        /// <summary>
 1911        /// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed.
 1912        /// </summary>
 1913        public virtual void ChangedExternally()
 1914        {
 01915            ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem)), RefreshPriori
 01916        }
 1917
 1918        /// <summary>
 1919        /// Gets an image.
 1920        /// </summary>
 1921        /// <param name="type">The type.</param>
 1922        /// <param name="imageIndex">Index of the image.</param>
 1923        /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
 1924        /// <exception cref="ArgumentException">Backdrops should be accessed using Item.Backdrops.</exception>
 1925        public bool HasImage(ImageType type, int imageIndex)
 1926        {
 1431927            return GetImageInfo(type, imageIndex) is not null;
 1928        }
 1929
 1930        public void SetImage(ItemImageInfo image, int index)
 1931        {
 131932            if (image.Type == ImageType.Chapter)
 1933            {
 01934                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1935            }
 1936
 131937            var existingImage = GetImageInfo(image.Type, index);
 1938
 131939            if (existingImage is null)
 1940            {
 111941                AddImage(image);
 1942            }
 1943            else
 1944            {
 21945                existingImage.Path = image.Path;
 21946                existingImage.DateModified = image.DateModified;
 21947                existingImage.Width = image.Width;
 21948                existingImage.Height = image.Height;
 21949                existingImage.BlurHash = image.BlurHash;
 1950            }
 21951        }
 1952
 1953        public void SetImagePath(ImageType type, int index, FileSystemMetadata file)
 1954        {
 461955            if (type == ImageType.Chapter)
 1956            {
 01957                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1958            }
 1959
 461960            var image = GetImageInfo(type, index);
 1961
 461962            if (image is null)
 1963            {
 451964                AddImage(GetImageInfo(file, type));
 1965            }
 1966            else
 1967            {
 11968                var imageInfo = GetImageInfo(file, type);
 1969
 11970                image.Path = file.FullName;
 11971                image.DateModified = imageInfo.DateModified;
 1972
 1973                // reset these values
 11974                image.Width = 0;
 11975                image.Height = 0;
 1976            }
 11977        }
 1978
 1979        /// <summary>
 1980        /// Deletes the image.
 1981        /// </summary>
 1982        /// <param name="type">The type.</param>
 1983        /// <param name="index">The index.</param>
 1984        /// <returns>A task.</returns>
 1985        public async Task DeleteImageAsync(ImageType type, int index)
 1986        {
 1987            var info = GetImageInfo(type, index);
 1988
 1989            if (info is null)
 1990            {
 1991                // Nothing to do
 1992                return;
 1993            }
 1994
 1995            // Remove from file system
 1996            var path = info.Path;
 1997            if (info.IsLocalFile && !string.IsNullOrWhiteSpace(path))
 1998            {
 1999                FileSystem.DeleteFile(path);
 2000            }
 2001
 2002            // Remove from item
 2003            RemoveImage(info);
 2004
 2005            await UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None).ConfigureAwait(false);
 2006        }
 2007
 2008        public void RemoveImage(ItemImageInfo image)
 2009        {
 02010            RemoveImages([image]);
 02011        }
 2012
 2013        public void RemoveImages(IEnumerable<ItemImageInfo> deletedImages)
 2014        {
 92015            ImageInfos = ImageInfos.Except(deletedImages).ToArray();
 92016        }
 2017
 2018        public void AddImage(ItemImageInfo image)
 2019        {
 562020            ImageInfos = [.. ImageInfos, image];
 562021        }
 2022
 2023        public virtual async Task UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationTok
 2024         => await LibraryManager.UpdateItemAsync(this, GetParent(), updateReason, cancellationToken).ConfigureAwait(fals
 2025
 2026        /// <summary>
 2027        /// Validates that images within the item are still on the filesystem.
 2028        /// </summary>
 2029        /// <returns><c>true</c> if the images validate, <c>false</c> if not.</returns>
 2030        public bool ValidateImages()
 2031        {
 672032            List<ItemImageInfo> deletedImages = null;
 1642033            foreach (var imageInfo in ImageInfos)
 2034            {
 152035                if (!imageInfo.IsLocalFile)
 2036                {
 2037                    continue;
 2038                }
 2039
 152040                if (File.Exists(imageInfo.Path))
 2041                {
 2042                    continue;
 2043                }
 2044
 32045                (deletedImages ??= []).Add(imageInfo);
 2046            }
 2047
 672048            var anyImagesRemoved = deletedImages?.Count > 0;
 672049            if (anyImagesRemoved)
 2050            {
 22051                RemoveImages(deletedImages);
 2052            }
 2053
 672054            return anyImagesRemoved;
 2055        }
 2056
 2057        /// <summary>
 2058        /// Gets the image path.
 2059        /// </summary>
 2060        /// <param name="imageType">Type of the image.</param>
 2061        /// <param name="imageIndex">Index of the image.</param>
 2062        /// <returns>System.String.</returns>
 2063        /// <exception cref="ArgumentNullException">Item is null.</exception>
 2064        public string GetImagePath(ImageType imageType, int imageIndex)
 22065            => GetImageInfo(imageType, imageIndex)?.Path;
 2066
 2067        /// <summary>
 2068        /// Gets the image information.
 2069        /// </summary>
 2070        /// <param name="imageType">Type of the image.</param>
 2071        /// <param name="imageIndex">Index of the image.</param>
 2072        /// <returns>ItemImageInfo.</returns>
 2073        public ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex)
 2074        {
 3152075            if (imageType == ImageType.Chapter)
 2076            {
 02077                var chapter = ChapterManager.GetChapter(Id, imageIndex);
 2078
 02079                if (chapter is null)
 2080                {
 02081                    return null;
 2082                }
 2083
 02084                var path = chapter.ImagePath;
 2085
 02086                if (string.IsNullOrEmpty(path))
 2087                {
 02088                    return null;
 2089                }
 2090
 02091                return new ItemImageInfo
 02092                {
 02093                    Path = path,
 02094                    DateModified = chapter.ImageDateModified,
 02095                    Type = imageType
 02096                };
 2097            }
 2098
 2099            // Music albums usually don't have dedicated backdrops, so return one from the artist instead
 3152100            if (GetType() == typeof(MusicAlbum) && imageType == ImageType.Backdrop)
 2101            {
 02102                var artist = FindParent<MusicArtist>();
 2103
 02104                if (artist is not null)
 2105                {
 02106                    return artist.GetImages(imageType).ElementAtOrDefault(imageIndex);
 2107                }
 2108            }
 2109
 3152110            return GetImages(imageType)
 3152111                .ElementAtOrDefault(imageIndex);
 2112        }
 2113
 2114        /// <summary>
 2115        /// Computes image index for given image or raises if no matching image found.
 2116        /// </summary>
 2117        /// <param name="image">Image to compute index for.</param>
 2118        /// <exception cref="ArgumentException">Image index cannot be computed as no matching image found.
 2119        /// </exception>
 2120        /// <returns>Image index.</returns>
 2121        public int GetImageIndex(ItemImageInfo image)
 2122        {
 02123            ArgumentNullException.ThrowIfNull(image);
 2124
 02125            if (image.Type == ImageType.Chapter)
 2126            {
 02127                var chapters = ChapterManager.GetChapters(Id);
 02128                for (var i = 0; i < chapters.Count; i++)
 2129                {
 02130                    if (chapters[i].ImagePath == image.Path)
 2131                    {
 02132                        return i;
 2133                    }
 2134                }
 2135
 02136                throw new ArgumentException("No chapter index found for image path", image.Path);
 2137            }
 2138
 02139            var images = GetImages(image.Type).ToArray();
 02140            for (var i = 0; i < images.Length; i++)
 2141            {
 02142                if (images[i].Path == image.Path)
 2143                {
 02144                    return i;
 2145                }
 2146            }
 2147
 02148            throw new ArgumentException("No image index found for image path", image.Path);
 2149        }
 2150
 2151        public IEnumerable<ItemImageInfo> GetImages(ImageType imageType)
 2152        {
 2153            if (imageType == ImageType.Chapter)
 2154            {
 2155                throw new ArgumentException("No image info for chapter images");
 2156            }
 2157
 2158            // Yield return is more performant than LINQ Where on an Array
 2159            for (var i = 0; i < ImageInfos.Length; i++)
 2160            {
 2161                var imageInfo = ImageInfos[i];
 2162                if (imageInfo.Type == imageType)
 2163                {
 2164                    yield return imageInfo;
 2165                }
 2166            }
 2167        }
 2168
 2169        /// <summary>
 2170        /// Adds the images, updating metadata if they already are part of this item.
 2171        /// </summary>
 2172        /// <param name="imageType">Type of the image.</param>
 2173        /// <param name="images">The images.</param>
 2174        /// <returns><c>true</c> if images were added or updated, <c>false</c> otherwise.</returns>
 2175        /// <exception cref="ArgumentException">Cannot call AddImages with chapter images.</exception>
 2176        public bool AddImages(ImageType imageType, List<FileSystemMetadata> images)
 2177        {
 672178            if (imageType == ImageType.Chapter)
 2179            {
 02180                throw new ArgumentException("Cannot call AddImages with chapter images");
 2181            }
 2182
 672183            var existingImages = GetImages(imageType)
 672184                .ToList();
 2185
 672186            var newImageList = new List<FileSystemMetadata>();
 672187            var imageUpdated = false;
 2188
 1502189            foreach (var newImage in images)
 2190            {
 82191                if (newImage is null)
 2192                {
 02193                    throw new ArgumentException("null image found in list");
 2194                }
 2195
 82196                var existing = existingImages
 82197                    .Find(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase));
 2198
 82199                if (existing is null)
 2200                {
 42201                    newImageList.Add(newImage);
 2202                }
 2203                else
 2204                {
 42205                    if (existing.IsLocalFile)
 2206                    {
 42207                        var newDateModified = FileSystem.GetLastWriteTimeUtc(newImage);
 2208
 2209                        // If date changed then we need to reset saved image dimensions
 42210                        if (existing.DateModified != newDateModified && (existing.Width > 0 || existing.Height > 0))
 2211                        {
 22212                            existing.Width = 0;
 22213                            existing.Height = 0;
 22214                            imageUpdated = true;
 2215                        }
 2216
 42217                        existing.DateModified = newDateModified;
 2218                    }
 2219                }
 2220            }
 2221
 672222            if (newImageList.Count > 0)
 2223            {
 22224                ImageInfos = ImageInfos.Concat(newImageList.Select(i => GetImageInfo(i, imageType))).ToArray();
 2225            }
 2226
 672227            return imageUpdated || newImageList.Count > 0;
 2228        }
 2229
 2230        private ItemImageInfo GetImageInfo(FileSystemMetadata file, ImageType type)
 2231        {
 502232            return new ItemImageInfo
 502233            {
 502234                Path = file.FullName,
 502235                Type = type,
 502236                DateModified = FileSystem.GetLastWriteTimeUtc(file)
 502237            };
 2238        }
 2239
 2240        /// <summary>
 2241        /// Gets the file system path to delete when the item is to be deleted.
 2242        /// </summary>
 2243        /// <returns>The metadata for the deleted paths.</returns>
 2244        public virtual IEnumerable<FileSystemMetadata> GetDeletePaths()
 2245        {
 02246            return new[]
 02247            {
 02248                FileSystem.GetFileSystemInfo(Path)
 02249            }.Concat(GetLocalMetadataFilesToDelete());
 2250        }
 2251
 2252        protected List<FileSystemMetadata> GetLocalMetadataFilesToDelete()
 2253        {
 02254            if (IsFolder || !IsInMixedFolder)
 2255            {
 02256                return [];
 2257            }
 2258
 02259            var filename = System.IO.Path.GetFileNameWithoutExtension(Path);
 2260
 02261            return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), _supportedExtensions, false, false)
 02262                .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison
 02263                .ToList();
 2264        }
 2265
 2266        public bool AllowsMultipleImages(ImageType type)
 2267        {
 182268            return type == ImageType.Backdrop || type == ImageType.Chapter;
 2269        }
 2270
 2271        public Task SwapImagesAsync(ImageType type, int index1, int index2)
 2272        {
 02273            if (!AllowsMultipleImages(type))
 2274            {
 02275                throw new ArgumentException("The change index operation is only applicable to backdrops and screen shots
 2276            }
 2277
 02278            var info1 = GetImageInfo(type, index1);
 02279            var info2 = GetImageInfo(type, index2);
 2280
 02281            if (info1 is null || info2 is null)
 2282            {
 2283                // Nothing to do
 02284                return Task.CompletedTask;
 2285            }
 2286
 02287            if (!info1.IsLocalFile || !info2.IsLocalFile)
 2288            {
 2289                // TODO: Not supported  yet
 02290                return Task.CompletedTask;
 2291            }
 2292
 02293            var path1 = info1.Path;
 02294            var path2 = info2.Path;
 2295
 02296            FileSystem.SwapFiles(path1, path2);
 2297
 2298            // Refresh these values
 02299            info1.DateModified = FileSystem.GetLastWriteTimeUtc(info1.Path);
 02300            info2.DateModified = FileSystem.GetLastWriteTimeUtc(info2.Path);
 2301
 02302            info1.Width = 0;
 02303            info1.Height = 0;
 02304            info2.Width = 0;
 02305            info2.Height = 0;
 2306
 02307            return UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None);
 2308        }
 2309
 2310        public virtual bool IsPlayed(User user)
 2311        {
 02312            var userdata = UserDataManager.GetUserData(user, this);
 2313
 02314            return userdata is not null && userdata.Played;
 2315        }
 2316
 2317        public bool IsFavoriteOrLiked(User user)
 2318        {
 02319            var userdata = UserDataManager.GetUserData(user, this);
 2320
 02321            return userdata is not null && (userdata.IsFavorite || (userdata.Likes ?? false));
 2322        }
 2323
 2324        public virtual bool IsUnplayed(User user)
 2325        {
 02326            ArgumentNullException.ThrowIfNull(user);
 2327
 02328            var userdata = UserDataManager.GetUserData(user, this);
 2329
 02330            return userdata is null || !userdata.Played;
 2331        }
 2332
 2333        ItemLookupInfo IHasLookupInfo<ItemLookupInfo>.GetLookupInfo()
 2334        {
 532335            return GetItemLookupInfo<ItemLookupInfo>();
 2336        }
 2337
 2338        protected T GetItemLookupInfo<T>()
 2339            where T : ItemLookupInfo, new()
 2340        {
 532341            return new T
 532342            {
 532343                Path = Path,
 532344                MetadataCountryCode = GetPreferredMetadataCountryCode(),
 532345                MetadataLanguage = GetPreferredMetadataLanguage(),
 532346                Name = GetNameForMetadataLookup(),
 532347                OriginalTitle = OriginalTitle,
 532348                ProviderIds = ProviderIds,
 532349                IndexNumber = IndexNumber,
 532350                ParentIndexNumber = ParentIndexNumber,
 532351                Year = ProductionYear,
 532352                PremiereDate = PremiereDate
 532353            };
 2354        }
 2355
 2356        protected virtual string GetNameForMetadataLookup()
 2357        {
 532358            return Name;
 2359        }
 2360
 2361        /// <summary>
 2362        /// This is called before any metadata refresh and returns true if changes were made.
 2363        /// </summary>
 2364        /// <param name="replaceAllMetadata">Whether to replace all metadata.</param>
 2365        /// <returns>true if the item has change, else false.</returns>
 2366        public virtual bool BeforeMetadataRefresh(bool replaceAllMetadata)
 2367        {
 532368            _sortName = null;
 2369
 532370            var hasChanges = false;
 2371
 532372            if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path))
 2373            {
 02374                Name = System.IO.Path.GetFileNameWithoutExtension(Path);
 02375                hasChanges = true;
 2376            }
 2377
 532378            return hasChanges;
 2379        }
 2380
 2381        protected static string GetMappedPath(BaseItem item, string path, MediaProtocol? protocol)
 2382        {
 02383            if (protocol == MediaProtocol.File)
 2384            {
 02385                return LibraryManager.GetPathAfterNetworkSubstitution(path, item);
 2386            }
 2387
 02388            return path;
 2389        }
 2390
 2391        public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User 
 2392        {
 02393            if (RunTimeTicks.HasValue)
 2394            {
 02395                double pct = RunTimeTicks.Value;
 2396
 02397                if (pct > 0)
 2398                {
 02399                    pct = userData.PlaybackPositionTicks / pct;
 2400
 02401                    if (pct > 0)
 2402                    {
 02403                        dto.PlayedPercentage = 100 * pct;
 2404                    }
 2405                }
 2406            }
 02407        }
 2408
 2409        protected async Task RefreshMetadataForOwnedItem(BaseItem ownedItem, bool copyTitleMetadata, MetadataRefreshOpti
 2410        {
 2411            var newOptions = new MetadataRefreshOptions(options)
 2412            {
 2413                SearchResult = null
 2414            };
 2415
 2416            var item = this;
 2417
 2418            if (copyTitleMetadata)
 2419            {
 2420                // Take some data from the main item, for querying purposes
 2421                if (!item.Genres.SequenceEqual(ownedItem.Genres, StringComparer.Ordinal))
 2422                {
 2423                    newOptions.ForceSave = true;
 2424                    ownedItem.Genres = item.Genres;
 2425                }
 2426
 2427                if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal))
 2428                {
 2429                    newOptions.ForceSave = true;
 2430                    ownedItem.Studios = item.Studios;
 2431                }
 2432
 2433                if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal))
 2434                {
 2435                    newOptions.ForceSave = true;
 2436                    ownedItem.ProductionLocations = item.ProductionLocations;
 2437                }
 2438
 2439                if (item.CommunityRating != ownedItem.CommunityRating)
 2440                {
 2441                    ownedItem.CommunityRating = item.CommunityRating;
 2442                    newOptions.ForceSave = true;
 2443                }
 2444
 2445                if (item.CriticRating != ownedItem.CriticRating)
 2446                {
 2447                    ownedItem.CriticRating = item.CriticRating;
 2448                    newOptions.ForceSave = true;
 2449                }
 2450
 2451                if (!string.Equals(item.Overview, ownedItem.Overview, StringComparison.Ordinal))
 2452                {
 2453                    ownedItem.Overview = item.Overview;
 2454                    newOptions.ForceSave = true;
 2455                }
 2456
 2457                if (!string.Equals(item.OfficialRating, ownedItem.OfficialRating, StringComparison.Ordinal))
 2458                {
 2459                    ownedItem.OfficialRating = item.OfficialRating;
 2460                    newOptions.ForceSave = true;
 2461                }
 2462
 2463                if (!string.Equals(item.CustomRating, ownedItem.CustomRating, StringComparison.Ordinal))
 2464                {
 2465                    ownedItem.CustomRating = item.CustomRating;
 2466                    newOptions.ForceSave = true;
 2467                }
 2468            }
 2469
 2470            await ownedItem.RefreshMetadata(newOptions, cancellationToken).ConfigureAwait(false);
 2471        }
 2472
 2473        protected async Task RefreshMetadataForOwnedVideo(MetadataRefreshOptions options, bool copyTitleMetadata, string
 2474        {
 2475            var newOptions = new MetadataRefreshOptions(options)
 2476            {
 2477                SearchResult = null
 2478            };
 2479
 2480            var id = LibraryManager.GetNewItemId(path, typeof(Video));
 2481
 2482            // Try to retrieve it from the db. If we don't find it, use the resolved version
 2483            if (LibraryManager.GetItemById(id) is not Video video)
 2484            {
 2485                video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video;
 2486
 2487                newOptions.ForceSave = true;
 2488            }
 2489
 2490            if (video is null)
 2491            {
 2492                return;
 2493            }
 2494
 2495            if (video.OwnerId.IsEmpty())
 2496            {
 2497                video.OwnerId = Id;
 2498            }
 2499
 2500            await RefreshMetadataForOwnedItem(video, copyTitleMetadata, newOptions, cancellationToken).ConfigureAwait(fa
 2501        }
 2502
 2503        public string GetEtag(User user)
 2504        {
 62505            var list = GetEtagValues(user);
 2506
 62507            return string.Join('|', list).GetMD5().ToString("N", CultureInfo.InvariantCulture);
 2508        }
 2509
 2510        protected virtual List<string> GetEtagValues(User user)
 2511        {
 62512            return
 62513            [
 62514                DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture)
 62515            ];
 2516        }
 2517
 2518        public virtual IEnumerable<Guid> GetAncestorIds()
 2519        {
 852520            return GetParents().Select(i => i.Id).Concat(LibraryManager.GetCollectionFolders(this).Select(i => i.Id));
 2521        }
 2522
 2523        public BaseItem GetTopParent()
 2524        {
 852525            if (IsTopParent)
 2526            {
 212527                return this;
 2528            }
 2529
 642530            return GetParents().FirstOrDefault(parent => parent.IsTopParent);
 2531        }
 2532
 2533        public virtual IEnumerable<Guid> GetIdsForAncestorQuery()
 2534        {
 382535            return [Id];
 2536        }
 2537
 2538        public virtual double? GetRefreshProgress()
 2539        {
 02540            return null;
 2541        }
 2542
 2543        public virtual ItemUpdateType OnMetadataChanged()
 2544        {
 1062545            var updateType = ItemUpdateType.None;
 2546
 1062547            var item = this;
 2548
 1062549            var rating = item.GetParentalRatingScore();
 1062550            if (rating is not null)
 2551            {
 02552                if (rating.Score != item.InheritedParentalRatingValue)
 2553                {
 02554                    item.InheritedParentalRatingValue = rating.Score;
 02555                    updateType |= ItemUpdateType.MetadataImport;
 2556                }
 2557
 02558                if (rating.SubScore != item.InheritedParentalRatingSubValue)
 2559                {
 02560                    item.InheritedParentalRatingSubValue = rating.SubScore;
 02561                    updateType |= ItemUpdateType.MetadataImport;
 2562                }
 2563            }
 2564            else
 2565            {
 1062566                if (item.InheritedParentalRatingValue is not null)
 2567                {
 02568                    item.InheritedParentalRatingValue = null;
 02569                    item.InheritedParentalRatingSubValue = null;
 02570                    updateType |= ItemUpdateType.MetadataImport;
 2571                }
 2572            }
 2573
 1062574            return updateType;
 2575        }
 2576
 2577        /// <summary>
 2578        /// Updates the official rating based on content and returns true or false indicating if it changed.
 2579        /// </summary>
 2580        /// <param name="children">Media children.</param>
 2581        /// <returns><c>true</c> if the rating was updated; otherwise <c>false</c>.</returns>
 2582        public bool UpdateRatingToItems(IReadOnlyList<BaseItem> children)
 2583        {
 02584            var currentOfficialRating = OfficialRating;
 2585
 2586            // Gather all possible ratings
 02587            var ratings = children
 02588                .Select(i => i.OfficialRating)
 02589                .Where(i => !string.IsNullOrEmpty(i))
 02590                .Distinct(StringComparer.OrdinalIgnoreCase)
 02591                .Select(rating => (rating, LocalizationManager.GetRatingScore(rating)))
 02592                .OrderBy(i => i.Item2 is null ? 1001 : i.Item2.Score)
 02593                .ThenBy(i => i.Item2 is null ? 1001 : i.Item2.SubScore)
 02594                .Select(i => i.rating);
 2595
 02596            OfficialRating = ratings.FirstOrDefault() ?? currentOfficialRating;
 2597
 02598            return !string.Equals(
 02599                currentOfficialRating ?? string.Empty,
 02600                OfficialRating ?? string.Empty,
 02601                StringComparison.OrdinalIgnoreCase);
 2602        }
 2603
 2604        public IReadOnlyList<BaseItem> GetThemeSongs(User user = null)
 2605        {
 02606            return GetThemeSongs(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2607        }
 2608
 2609        public IReadOnlyList<BaseItem> GetThemeSongs(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> or
 2610        {
 02611            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeSong), user, 
 2612        }
 2613
 2614        public IReadOnlyList<BaseItem> GetThemeVideos(User user = null)
 2615        {
 02616            return GetThemeVideos(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2617        }
 2618
 2619        public IReadOnlyList<BaseItem> GetThemeVideos(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> o
 2620        {
 02621            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeVideo), user,
 2622        }
 2623
 2624        /// <summary>
 2625        /// Get all extras associated with this item, sorted by <see cref="SortName"/>.
 2626        /// </summary>
 2627        /// <returns>An enumerable containing the items.</returns>
 2628        public IEnumerable<BaseItem> GetExtras()
 2629        {
 62630            return ExtraIds
 62631                .Select(LibraryManager.GetItemById)
 62632                .Where(i => i is not null)
 62633                .OrderBy(i => i.SortName);
 2634        }
 2635
 2636        /// <summary>
 2637        /// Get all extras with specific types that are associated with this item.
 2638        /// </summary>
 2639        /// <param name="extraTypes">The types of extras to retrieve.</param>
 2640        /// <returns>An enumerable containing the extras.</returns>
 2641        public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
 2642        {
 02643            return ExtraIds
 02644                .Select(LibraryManager.GetItemById)
 02645                .Where(i => i is not null)
 02646                .Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value))
 02647                .OrderBy(i => i.SortName);
 2648        }
 2649
 2650        public virtual long GetRunTimeTicksForPlayState()
 2651        {
 02652            return RunTimeTicks ?? 0;
 2653        }
 2654
 2655        /// <inheritdoc />
 2656        public override bool Equals(object obj)
 2657        {
 02658            return obj is BaseItem baseItem && this.Equals(baseItem);
 2659        }
 2660
 2661        /// <inheritdoc />
 72662        public bool Equals(BaseItem other) => other is not null && other.Id.Equals(Id);
 2663
 2664        /// <inheritdoc />
 512665        public override int GetHashCode() => HashCode.Combine(Id);
 2666    }
 2667}

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()
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)
IsFavoriteOrLiked(Jellyfin.Database.Implementations.Entities.User)
IsUnplayed(Jellyfin.Database.Implementations.Entities.User)
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()