< 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: 375
Uncovered lines: 355
Coverable lines: 730
Total lines: 2675
Line coverage: 51.3%
Branch coverage
41%
Covered branches: 186
Total branches: 452
Branch coverage: 41.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

0255075100

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()40%151062.5%
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        {
 974101            Tags = Array.Empty<string>();
 974102            Genres = Array.Empty<string>();
 974103            Studios = Array.Empty<string>();
 974104            ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 974105            LockedFields = Array.Empty<MetadataField>();
 974106            ImageInfos = Array.Empty<ItemImageInfo>();
 974107            ProductionLocations = Array.Empty<string>();
 974108            RemoteTrailers = Array.Empty<MediaUrl>();
 974109            ExtraIds = Array.Empty<Guid>();
 974110        }
 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        {
 976188            get => _name;
 189            set
 190            {
 370191                _name = value;
 192
 193                // lazy load this again
 370194                _sortName = null;
 370195            }
 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            {
 1957257                if (!ChannelId.IsEmpty())
 258                {
 0259                    return SourceType.Channel;
 260                }
 261
 1957262                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            {
 393275                if (IsFolder)
 276                {
 342277                    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            {
 2493335                var path = Path;
 336
 2493337                if (string.IsNullOrEmpty(path))
 338                {
 116339                    return null;
 340                }
 341
 2377342                return MediaSourceManager.GetPathProtocol(path);
 343            }
 344        }
 345
 346        [JsonIgnore]
 2472347        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            {
 1312357                if (SourceType == SourceType.Channel)
 358                {
 0359                    return false;
 360                }
 361
 1312362                return IsFileProtocol;
 363            }
 364        }
 365
 366        [JsonIgnore]
 367        public virtual string FileNameWithoutExtension
 368        {
 369            get
 370            {
 0371                if (IsFileProtocol)
 372                {
 0373                    return System.IO.Path.GetFileNameWithoutExtension(Path);
 374                }
 375
 0376                return null;
 377            }
 378        }
 379
 380        [JsonIgnore]
 105381        public virtual bool EnableAlphaNumericSorting => true;
 382
 110383        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]
 101439        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        {
 448506            get => _forcedSortName;
 507            set
 508            {
 109509                _forcedSortName = value;
 109510                _sortName = null;
 109511            }
 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            {
 141523                if (_sortName is null)
 524                {
 105525                    if (!string.IsNullOrEmpty(ForcedSortName))
 526                    {
 527                        // Need the ToLower because that's what CreateSortName does
 0528                        _sortName = ModifySortChunks(ForcedSortName).ToLowerInvariant();
 529                    }
 530                    else
 531                    {
 105532                        _sortName = CreateSortName();
 533                    }
 534                }
 535
 141536                return _sortName;
 537            }
 538
 138539            set => _sortName = value;
 540        }
 541
 542        [JsonIgnore]
 346543        public virtual Guid DisplayParentId => ParentId;
 544
 545        [JsonIgnore]
 546        public BaseItem DisplayParent
 547        {
 548            get
 549            {
 340550                var id = DisplayParentId;
 340551                if (id.IsEmpty())
 552                {
 250553                    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            {
 170683                var officialRating = OfficialRating;
 170684                if (!string.IsNullOrEmpty(officialRating))
 685                {
 0686                    return officialRating;
 687                }
 688
 170689                var parent = DisplayParent;
 170690                if (parent is not null)
 691                {
 45692                    return parent.OfficialRatingForComparison;
 693                }
 694
 125695                return null;
 696            }
 697        }
 698
 699        [JsonIgnore]
 700        public string CustomRatingForComparison
 701        {
 702            get
 703            {
 170704                var customRating = CustomRating;
 170705                if (!string.IsNullOrEmpty(customRating))
 706                {
 0707                    return customRating;
 708                }
 709
 170710                var parent = DisplayParent;
 170711                if (parent is not null)
 712                {
 45713                    return parent.CustomRatingForComparison;
 714                }
 715
 125716                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            {
 242741                if (this is BasePluginFolder || this is Channel)
 742                {
 53743                    return true;
 744                }
 745
 189746                if (this is IHasCollectionType view)
 747                {
 16748                    if (view.CollectionType == CollectionType.livetv)
 749                    {
 0750                        return true;
 751                    }
 752                }
 753
 189754                if (GetParent() is AggregateFolder)
 755                {
 0756                    return true;
 757                }
 758
 189759                return false;
 760            }
 761        }
 762
 763        [JsonIgnore]
 184764        public virtual bool SupportsAncestors => true;
 765
 766        [JsonIgnore]
 90767        protected virtual bool SupportsOwnedItems => !ParentId.IsEmpty() && IsFileProtocol;
 768
 769        [JsonIgnore]
 70770        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        {
 56801            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        {
 670843            var ownerId = OwnerId;
 670844            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        {
 70882            var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath;
 883
 70884            return GetInternalMetadataPath(basePath);
 885        }
 886
 887        protected virtual string GetInternalMetadataPath(string basePath)
 888        {
 70889            if (SourceType == SourceType.Channel)
 890            {
 0891                return System.IO.Path.Join(basePath, "channels", ChannelId.ToString("N", CultureInfo.InvariantCulture), 
 892            }
 893
 70894            ReadOnlySpan<char> idString = Id.ToString("N", CultureInfo.InvariantCulture);
 895
 70896            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        {
 105905            if (Name is null)
 906            {
 0907                return null; // some items may not have name filled in properly
 908            }
 909
 105910            if (!EnableAlphaNumericSorting)
 911            {
 0912                return Name.TrimStart();
 913            }
 914
 105915            var sortable = Name.Trim().ToLowerInvariant();
 916
 840917            foreach (var search in ConfigurationManager.Configuration.SortRemoveWords)
 918            {
 919                // Remove from beginning if a space follows
 315920                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
 315926                sortable = sortable.Replace(" " + search + " ", " ", StringComparison.Ordinal);
 927
 928                // Remove from end if preceeded by a space
 315929                if (sortable.EndsWith(" " + search, StringComparison.Ordinal))
 930                {
 0931                    sortable = sortable.Remove(sortable.Length - (search.Length + 1));
 932                }
 933            }
 934
 1470935            foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters)
 936            {
 630937                sortable = sortable.Replace(removeChar, string.Empty, StringComparison.Ordinal);
 938            }
 939
 840940            foreach (var replaceChar in ConfigurationManager.Configuration.SortReplaceCharacters)
 941            {
 315942                sortable = sortable.Replace(replaceChar, " ", StringComparison.Ordinal);
 943            }
 944
 105945            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
 111960            if (name.IsEmpty)
 961            {
 1962                return string.Empty;
 963            }
 964
 110965            var builder = new StringBuilder(name.Length);
 966
 110967            int chunkStart = 0;
 110968            bool isDigitChunk = char.IsDigit(name[0]);
 1782969            for (int i = 0; i < name.Length; i++)
 970            {
 781971                var isDigit = char.IsDigit(name[i]);
 781972                if (isDigit != isDigitChunk)
 973                {
 7974                    AppendChunk(builder, isDigitChunk, name.Slice(chunkStart, i - chunkStart));
 7975                    chunkStart = i;
 7976                    isDigitChunk = isDigit;
 977                }
 978            }
 979
 110980            AppendChunk(builder, isDigitChunk, name.Slice(chunkStart));
 981
 982            // logger.LogDebug("ModifySortChunks Start: {0} End: {1}", name, builder.ToString());
 110983            var result = builder.ToString().RemoveDiacritics();
 110984            if (!result.All(char.IsAscii))
 985            {
 0986                result = result.Transliterated();
 987            }
 988
 110989            return result;
 990        }
 991
 992        public BaseItem GetParent()
 993        {
 1667994            var parentId = ParentId;
 1667995            if (parentId.IsEmpty())
 996            {
 1323997                return null;
 998            }
 999
 3441000            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        {
 481265            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        {
 141343            ParentId = parent is null ? Guid.Empty : parent.Id;
 141344        }
 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        {
 361366            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        {
 561426            if (string.IsNullOrEmpty(Path) || DateModified == default)
 1427            {
 01428                return false;
 1429            }
 1430
 561431            var info = FileSystem.GetFileSystemInfo(Path);
 561432            if (info.Exists)
 1433            {
 561434                if (info.IsDirectory)
 1435                {
 561436                    return info.LastWriteTimeUtc != DateModified;
 1437                }
 1438
 01439                return info.LastWriteTimeUtc != DateModified && info.Length != (Size ?? 0);
 1440            }
 1441
 01442            return false;
 1443        }
 1444
 1445        public virtual List<string> GetUserDataKeys()
 1446        {
 1011447            var list = new List<string>();
 1448
 1011449            if (SourceType == SourceType.Channel)
 1450            {
 01451                if (!string.IsNullOrEmpty(ExternalId))
 1452                {
 01453                    list.Add(ExternalId);
 1454                }
 1455            }
 1456
 1011457            list.Add(Id.ToString());
 1011458            return list;
 1459        }
 1460
 1461        internal virtual ItemUpdateType UpdateFromResolvedItem(BaseItem newItem)
 1462        {
 61463            var updateType = ItemUpdateType.None;
 1464
 61465            if (IsInMixedFolder != newItem.IsInMixedFolder)
 1466            {
 01467                IsInMixedFolder = newItem.IsInMixedFolder;
 01468                updateType |= ItemUpdateType.MetadataImport;
 1469            }
 1470
 61471            return updateType;
 1472        }
 1473
 1474        public void AfterMetadataRefresh()
 1475        {
 551476            _sortName = null;
 551477        }
 1478
 1479        /// <summary>
 1480        /// Gets the preferred metadata language.
 1481        /// </summary>
 1482        /// <returns>System.String.</returns>
 1483        public string GetPreferredMetadataLanguage()
 1484        {
 561485            string lang = PreferredMetadataLanguage;
 1486
 561487            if (string.IsNullOrEmpty(lang))
 1488            {
 561489                lang = GetParents()
 561490                    .Select(i => i.PreferredMetadataLanguage)
 561491                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1492            }
 1493
 561494            if (string.IsNullOrEmpty(lang))
 1495            {
 561496                lang = LibraryManager.GetCollectionFolders(this)
 561497                    .Select(i => i.PreferredMetadataLanguage)
 561498                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1499            }
 1500
 561501            if (string.IsNullOrEmpty(lang))
 1502            {
 561503                lang = LibraryManager.GetLibraryOptions(this).PreferredMetadataLanguage;
 1504            }
 1505
 561506            if (string.IsNullOrEmpty(lang))
 1507            {
 561508                lang = ConfigurationManager.Configuration.PreferredMetadataLanguage;
 1509            }
 1510
 561511            return lang;
 1512        }
 1513
 1514        /// <summary>
 1515        /// Gets the preferred metadata language.
 1516        /// </summary>
 1517        /// <returns>System.String.</returns>
 1518        public string GetPreferredMetadataCountryCode()
 1519        {
 561520            string lang = PreferredMetadataCountryCode;
 1521
 561522            if (string.IsNullOrEmpty(lang))
 1523            {
 561524                lang = GetParents()
 561525                    .Select(i => i.PreferredMetadataCountryCode)
 561526                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1527            }
 1528
 561529            if (string.IsNullOrEmpty(lang))
 1530            {
 561531                lang = LibraryManager.GetCollectionFolders(this)
 561532                    .Select(i => i.PreferredMetadataCountryCode)
 561533                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1534            }
 1535
 561536            if (string.IsNullOrEmpty(lang))
 1537            {
 561538                lang = LibraryManager.GetLibraryOptions(this).MetadataCountryCode;
 1539            }
 1540
 561541            if (string.IsNullOrEmpty(lang))
 1542            {
 561543                lang = ConfigurationManager.Configuration.MetadataCountryCode;
 1544            }
 1545
 561546            return lang;
 1547        }
 1548
 1549        public virtual bool IsSaveLocalMetadataEnabled()
 1550        {
 801551            if (SourceType == SourceType.Channel)
 1552            {
 01553                return false;
 1554            }
 1555
 801556            var libraryOptions = LibraryManager.GetLibraryOptions(this);
 1557
 801558            return libraryOptions.SaveLocalMetadata;
 1559        }
 1560
 1561        /// <summary>
 1562        /// Determines if a given user has access to this item.
 1563        /// </summary>
 1564        /// <param name="user">The user.</param>
 1565        /// <param name="skipAllowedTagsCheck">Don't check for allowed tags.</param>
 1566        /// <returns><c>true</c> if [is parental allowed] [the specified user]; otherwise, <c>false</c>.</returns>
 1567        /// <exception cref="ArgumentNullException">If user is null.</exception>
 1568        public bool IsParentalAllowed(User user, bool skipAllowedTagsCheck)
 1569        {
 131570            ArgumentNullException.ThrowIfNull(user);
 1571
 131572            if (!IsVisibleViaTags(user, skipAllowedTagsCheck))
 1573            {
 01574                return false;
 1575            }
 1576
 131577            var maxAllowedRating = user.MaxParentalRatingScore;
 131578            var maxAllowedSubRating = user.MaxParentalRatingSubScore;
 131579            var rating = CustomRatingForComparison;
 1580
 131581            if (string.IsNullOrEmpty(rating))
 1582            {
 131583                rating = OfficialRatingForComparison;
 1584            }
 1585
 131586            if (string.IsNullOrEmpty(rating))
 1587            {
 131588                Logger.LogDebug("{0} has no parental rating set.", Name);
 131589                return !GetBlockUnratedValue(user);
 1590            }
 1591
 01592            var ratingScore = LocalizationManager.GetRatingScore(rating);
 1593
 1594            // Could not determine rating level
 01595            if (ratingScore is null)
 1596            {
 01597                var isAllowed = !GetBlockUnratedValue(user);
 1598
 01599                if (!isAllowed)
 1600                {
 01601                    Logger.LogDebug("{0} has an unrecognized parental rating of {1}.", Name, rating);
 1602                }
 1603
 01604                return isAllowed;
 1605            }
 1606
 01607            if (maxAllowedSubRating is not null)
 1608            {
 01609                return (ratingScore.SubScore ?? 0) <= maxAllowedSubRating && ratingScore.Score <= maxAllowedRating.Value
 1610            }
 1611
 01612            return !maxAllowedRating.HasValue || ratingScore.Score <= maxAllowedRating.Value;
 1613        }
 1614
 1615        public ParentalRatingScore GetParentalRatingScore()
 1616        {
 1121617            var rating = CustomRatingForComparison;
 1618
 1121619            if (string.IsNullOrEmpty(rating))
 1620            {
 1121621                rating = OfficialRatingForComparison;
 1622            }
 1623
 1121624            if (string.IsNullOrEmpty(rating))
 1625            {
 1121626                return null;
 1627            }
 1628
 01629            return LocalizationManager.GetRatingScore(rating);
 1630        }
 1631
 1632        public List<string> GetInheritedTags()
 1633        {
 1051634            var list = new List<string>();
 1051635            list.AddRange(Tags);
 1636
 2521637            foreach (var parent in GetParents())
 1638            {
 211639                list.AddRange(parent.Tags);
 1640            }
 1641
 2101642            foreach (var folder in LibraryManager.GetCollectionFolders(this))
 1643            {
 01644                list.AddRange(folder.Tags);
 1645            }
 1646
 1051647            return list.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
 1648        }
 1649
 1650        private bool IsVisibleViaTags(User user, bool skipAllowedTagsCheck)
 1651        {
 131652            var allTags = GetInheritedTags();
 131653            if (user.GetPreference(PreferenceKind.BlockedTags).Any(i => allTags.Contains(i, StringComparison.OrdinalIgno
 1654            {
 01655                return false;
 1656            }
 1657
 131658            var parent = GetParents().FirstOrDefault() ?? this;
 131659            if (parent is UserRootFolder or AggregateFolder or UserView)
 1660            {
 131661                return true;
 1662            }
 1663
 01664            var allowedTagsPreference = user.GetPreference(PreferenceKind.AllowedTags);
 01665            if (!skipAllowedTagsCheck && allowedTagsPreference.Length != 0 && !allowedTagsPreference.Any(i => allTags.Co
 1666            {
 01667                return false;
 1668            }
 1669
 01670            return true;
 1671        }
 1672
 1673        public virtual UnratedItem GetBlockUnratedType()
 1674        {
 921675            if (SourceType == SourceType.Channel)
 1676            {
 01677                return UnratedItem.ChannelContent;
 1678            }
 1679
 921680            return UnratedItem.Other;
 1681        }
 1682
 1683        /// <summary>
 1684        /// Gets a bool indicating if access to the unrated item is blocked or not.
 1685        /// </summary>
 1686        /// <param name="user">The configuration.</param>
 1687        /// <returns><c>true</c> if blocked, <c>false</c> otherwise.</returns>
 1688        protected virtual bool GetBlockUnratedValue(User user)
 1689        {
 1690            // Don't block plain folders that are unrated. Let the media underneath get blocked
 1691            // Special folders like series and albums will override this method.
 131692            if (IsFolder || this is IItemByName)
 1693            {
 131694                return false;
 1695            }
 1696
 01697            return user.GetPreferenceValues<UnratedItem>(PreferenceKind.BlockUnratedItems).Contains(GetBlockUnratedType(
 1698        }
 1699
 1700        /// <summary>
 1701        /// Determines if this folder should be visible to a given user.
 1702        /// Default is just parental allowed. Can be overridden for more functionality.
 1703        /// </summary>
 1704        /// <param name="user">The user.</param>
 1705        /// <param name="skipAllowedTagsCheck">Don't check for allowed tags.</param>
 1706        /// <returns><c>true</c> if the specified user is visible; otherwise, <c>false</c>.</returns>
 1707        /// <exception cref="ArgumentNullException"><paramref name="user" /> is <c>null</c>.</exception>
 1708        public virtual bool IsVisible(User user, bool skipAllowedTagsCheck = false)
 1709        {
 131710            ArgumentNullException.ThrowIfNull(user);
 1711
 131712            return IsParentalAllowed(user, skipAllowedTagsCheck);
 1713        }
 1714
 1715        public virtual bool IsVisibleStandalone(User user)
 1716        {
 01717            if (SourceType == SourceType.Channel)
 1718            {
 01719                return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
 1720            }
 1721
 01722            return IsVisibleStandaloneInternal(user, true);
 1723        }
 1724
 1725        public virtual string GetClientTypeName()
 1726        {
 791727            if (IsFolder && SourceType == SourceType.Channel && this is not Channel && this is not Season && this is not
 1728            {
 01729                return "ChannelFolderItem";
 1730            }
 1731
 791732            return GetType().Name;
 1733        }
 1734
 1735        public BaseItemKind GetBaseItemKind()
 1736        {
 2591737            return _baseItemKind ??= Enum.Parse<BaseItemKind>(GetClientTypeName());
 1738        }
 1739
 1740        /// <summary>
 1741        /// Gets the linked child.
 1742        /// </summary>
 1743        /// <param name="info">The info.</param>
 1744        /// <returns>BaseItem.</returns>
 1745        protected BaseItem GetLinkedChild(LinkedChild info)
 1746        {
 1747            // First get using the cached Id
 01748            if (info.ItemId.HasValue)
 1749            {
 01750                if (info.ItemId.Value.IsEmpty())
 1751                {
 01752                    return null;
 1753                }
 1754
 01755                var itemById = LibraryManager.GetItemById(info.ItemId.Value);
 1756
 01757                if (itemById is not null)
 1758                {
 01759                    return itemById;
 1760                }
 1761            }
 1762
 01763            var item = FindLinkedChild(info);
 1764
 1765            // If still null, log
 01766            if (item is null)
 1767            {
 1768                // Don't keep searching over and over
 01769                info.ItemId = Guid.Empty;
 1770            }
 1771            else
 1772            {
 1773                // Cache the id for next time
 01774                info.ItemId = item.Id;
 1775            }
 1776
 01777            return item;
 1778        }
 1779
 1780        private BaseItem FindLinkedChild(LinkedChild info)
 1781        {
 01782            var path = info.Path;
 1783
 01784            if (!string.IsNullOrEmpty(path))
 1785            {
 01786                path = FileSystem.MakeAbsolutePath(ContainingFolderPath, path);
 1787
 01788                var itemByPath = LibraryManager.FindByPath(path, null);
 1789
 01790                if (itemByPath is null)
 1791                {
 01792                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1793                }
 1794
 01795                return itemByPath;
 1796            }
 1797
 01798            if (!string.IsNullOrEmpty(info.LibraryItemId))
 1799            {
 01800                var item = LibraryManager.GetItemById(info.LibraryItemId);
 1801
 01802                if (item is null)
 1803                {
 01804                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1805                }
 1806
 01807                return item;
 1808            }
 1809
 01810            return null;
 1811        }
 1812
 1813        /// <summary>
 1814        /// Adds a studio to the item.
 1815        /// </summary>
 1816        /// <param name="name">The name.</param>
 1817        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1818        public void AddStudio(string name)
 1819        {
 41820            ArgumentException.ThrowIfNullOrEmpty(name);
 41821            var current = Studios;
 1822
 41823            if (!current.Contains(name, StringComparison.OrdinalIgnoreCase))
 1824            {
 41825                int curLen = current.Length;
 41826                if (curLen == 0)
 1827                {
 41828                    Studios = [name];
 1829                }
 1830                else
 1831                {
 01832                    Studios = [.. current, name];
 1833                }
 1834            }
 01835        }
 1836
 1837        public void SetStudios(IEnumerable<string> names)
 1838        {
 01839            Studios = names.Trimmed().Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
 01840        }
 1841
 1842        /// <summary>
 1843        /// Adds a genre to the item.
 1844        /// </summary>
 1845        /// <param name="name">The name.</param>
 1846        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1847        public void AddGenre(string name)
 1848        {
 131849            ArgumentException.ThrowIfNullOrEmpty(name);
 1850
 131851            var genres = Genres;
 131852            if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))
 1853            {
 131854                Genres = [.. genres, name];
 1855            }
 131856        }
 1857
 1858        /// <summary>
 1859        /// Marks the played.
 1860        /// </summary>
 1861        /// <param name="user">The user.</param>
 1862        /// <param name="datePlayed">The date played.</param>
 1863        /// <param name="resetPosition">if set to <c>true</c> [reset position].</param>
 1864        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1865        public virtual void MarkPlayed(
 1866            User user,
 1867            DateTime? datePlayed,
 1868            bool resetPosition)
 1869        {
 01870            ArgumentNullException.ThrowIfNull(user);
 1871
 01872            var data = UserDataManager.GetUserData(user, this) ?? new UserItemData()
 01873            {
 01874                Key = GetUserDataKeys().First(),
 01875            };
 1876
 01877            if (datePlayed.HasValue)
 1878            {
 1879                // Increment
 01880                data.PlayCount++;
 1881            }
 1882
 1883            // Ensure it's at least one
 01884            data.PlayCount = Math.Max(data.PlayCount, 1);
 1885
 01886            if (resetPosition)
 1887            {
 01888                data.PlaybackPositionTicks = 0;
 1889            }
 1890
 01891            data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
 01892            data.Played = true;
 1893
 01894            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01895        }
 1896
 1897        /// <summary>
 1898        /// Marks the unplayed.
 1899        /// </summary>
 1900        /// <param name="user">The user.</param>
 1901        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1902        public virtual void MarkUnplayed(User user)
 1903        {
 01904            ArgumentNullException.ThrowIfNull(user);
 1905
 01906            var data = UserDataManager.GetUserData(user, this);
 1907
 1908            // I think it is okay to do this here.
 1909            // if this is only called when a user is manually forcing something to un-played
 1910            // then it probably is what we want to do...
 01911            data.PlayCount = 0;
 01912            data.PlaybackPositionTicks = 0;
 01913            data.LastPlayedDate = null;
 01914            data.Played = false;
 1915
 01916            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01917        }
 1918
 1919        /// <summary>
 1920        /// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed.
 1921        /// </summary>
 1922        public virtual void ChangedExternally()
 1923        {
 01924            ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem)), RefreshPriori
 01925        }
 1926
 1927        /// <summary>
 1928        /// Gets an image.
 1929        /// </summary>
 1930        /// <param name="type">The type.</param>
 1931        /// <param name="imageIndex">Index of the image.</param>
 1932        /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
 1933        /// <exception cref="ArgumentException">Backdrops should be accessed using Item.Backdrops.</exception>
 1934        public bool HasImage(ImageType type, int imageIndex)
 1935        {
 1431936            return GetImageInfo(type, imageIndex) is not null;
 1937        }
 1938
 1939        public void SetImage(ItemImageInfo image, int index)
 1940        {
 131941            if (image.Type == ImageType.Chapter)
 1942            {
 01943                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1944            }
 1945
 131946            var existingImage = GetImageInfo(image.Type, index);
 1947
 131948            if (existingImage is null)
 1949            {
 111950                AddImage(image);
 1951            }
 1952            else
 1953            {
 21954                existingImage.Path = image.Path;
 21955                existingImage.DateModified = image.DateModified;
 21956                existingImage.Width = image.Width;
 21957                existingImage.Height = image.Height;
 21958                existingImage.BlurHash = image.BlurHash;
 1959            }
 21960        }
 1961
 1962        public void SetImagePath(ImageType type, int index, FileSystemMetadata file)
 1963        {
 461964            if (type == ImageType.Chapter)
 1965            {
 01966                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1967            }
 1968
 461969            var image = GetImageInfo(type, index);
 1970
 461971            if (image is null)
 1972            {
 451973                AddImage(GetImageInfo(file, type));
 1974            }
 1975            else
 1976            {
 11977                var imageInfo = GetImageInfo(file, type);
 1978
 11979                image.Path = file.FullName;
 11980                image.DateModified = imageInfo.DateModified;
 1981
 1982                // reset these values
 11983                image.Width = 0;
 11984                image.Height = 0;
 1985            }
 11986        }
 1987
 1988        /// <summary>
 1989        /// Deletes the image.
 1990        /// </summary>
 1991        /// <param name="type">The type.</param>
 1992        /// <param name="index">The index.</param>
 1993        /// <returns>A task.</returns>
 1994        public async Task DeleteImageAsync(ImageType type, int index)
 1995        {
 1996            var info = GetImageInfo(type, index);
 1997
 1998            if (info is null)
 1999            {
 2000                // Nothing to do
 2001                return;
 2002            }
 2003
 2004            // Remove from file system
 2005            if (info.IsLocalFile)
 2006            {
 2007                FileSystem.DeleteFile(info.Path);
 2008            }
 2009
 2010            // Remove from item
 2011            RemoveImage(info);
 2012
 2013            await UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None).ConfigureAwait(false);
 2014        }
 2015
 2016        public void RemoveImage(ItemImageInfo image)
 2017        {
 02018            RemoveImages([image]);
 02019        }
 2020
 2021        public void RemoveImages(IEnumerable<ItemImageInfo> deletedImages)
 2022        {
 92023            ImageInfos = ImageInfos.Except(deletedImages).ToArray();
 92024        }
 2025
 2026        public void AddImage(ItemImageInfo image)
 2027        {
 562028            ImageInfos = [.. ImageInfos, image];
 562029        }
 2030
 2031        public virtual async Task UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationTok
 2032         => await LibraryManager.UpdateItemAsync(this, GetParent(), updateReason, cancellationToken).ConfigureAwait(fals
 2033
 2034        /// <summary>
 2035        /// Validates that images within the item are still on the filesystem.
 2036        /// </summary>
 2037        /// <returns><c>true</c> if the images validate, <c>false</c> if not.</returns>
 2038        public bool ValidateImages()
 2039        {
 702040            List<ItemImageInfo> deletedImages = null;
 1702041            foreach (var imageInfo in ImageInfos)
 2042            {
 152043                if (!imageInfo.IsLocalFile)
 2044                {
 2045                    continue;
 2046                }
 2047
 152048                if (File.Exists(imageInfo.Path))
 2049                {
 2050                    continue;
 2051                }
 2052
 32053                (deletedImages ??= []).Add(imageInfo);
 2054            }
 2055
 702056            var anyImagesRemoved = deletedImages?.Count > 0;
 702057            if (anyImagesRemoved)
 2058            {
 22059                RemoveImages(deletedImages);
 2060            }
 2061
 702062            return anyImagesRemoved;
 2063        }
 2064
 2065        /// <summary>
 2066        /// Gets the image path.
 2067        /// </summary>
 2068        /// <param name="imageType">Type of the image.</param>
 2069        /// <param name="imageIndex">Index of the image.</param>
 2070        /// <returns>System.String.</returns>
 2071        /// <exception cref="ArgumentNullException">Item is null.</exception>
 2072        public string GetImagePath(ImageType imageType, int imageIndex)
 22073            => GetImageInfo(imageType, imageIndex)?.Path;
 2074
 2075        /// <summary>
 2076        /// Gets the image information.
 2077        /// </summary>
 2078        /// <param name="imageType">Type of the image.</param>
 2079        /// <param name="imageIndex">Index of the image.</param>
 2080        /// <returns>ItemImageInfo.</returns>
 2081        public ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex)
 2082        {
 3182083            if (imageType == ImageType.Chapter)
 2084            {
 02085                var chapter = ChapterManager.GetChapter(Id, imageIndex);
 2086
 02087                if (chapter is null)
 2088                {
 02089                    return null;
 2090                }
 2091
 02092                var path = chapter.ImagePath;
 2093
 02094                if (string.IsNullOrEmpty(path))
 2095                {
 02096                    return null;
 2097                }
 2098
 02099                return new ItemImageInfo
 02100                {
 02101                    Path = path,
 02102                    DateModified = chapter.ImageDateModified,
 02103                    Type = imageType
 02104                };
 2105            }
 2106
 2107            // Music albums usually don't have dedicated backdrops, so return one from the artist instead
 3182108            if (GetType() == typeof(MusicAlbum) && imageType == ImageType.Backdrop)
 2109            {
 02110                var artist = FindParent<MusicArtist>();
 2111
 02112                if (artist is not null)
 2113                {
 02114                    return artist.GetImages(imageType).ElementAtOrDefault(imageIndex);
 2115                }
 2116            }
 2117
 3182118            return GetImages(imageType)
 3182119                .ElementAtOrDefault(imageIndex);
 2120        }
 2121
 2122        /// <summary>
 2123        /// Computes image index for given image or raises if no matching image found.
 2124        /// </summary>
 2125        /// <param name="image">Image to compute index for.</param>
 2126        /// <exception cref="ArgumentException">Image index cannot be computed as no matching image found.
 2127        /// </exception>
 2128        /// <returns>Image index.</returns>
 2129        public int GetImageIndex(ItemImageInfo image)
 2130        {
 02131            ArgumentNullException.ThrowIfNull(image);
 2132
 02133            if (image.Type == ImageType.Chapter)
 2134            {
 02135                var chapters = ChapterManager.GetChapters(Id);
 02136                for (var i = 0; i < chapters.Count; i++)
 2137                {
 02138                    if (chapters[i].ImagePath == image.Path)
 2139                    {
 02140                        return i;
 2141                    }
 2142                }
 2143
 02144                throw new ArgumentException("No chapter index found for image path", image.Path);
 2145            }
 2146
 02147            var images = GetImages(image.Type).ToArray();
 02148            for (var i = 0; i < images.Length; i++)
 2149            {
 02150                if (images[i].Path == image.Path)
 2151                {
 02152                    return i;
 2153                }
 2154            }
 2155
 02156            throw new ArgumentException("No image index found for image path", image.Path);
 2157        }
 2158
 2159        public IEnumerable<ItemImageInfo> GetImages(ImageType imageType)
 2160        {
 2161            if (imageType == ImageType.Chapter)
 2162            {
 2163                throw new ArgumentException("No image info for chapter images");
 2164            }
 2165
 2166            // Yield return is more performant than LINQ Where on an Array
 2167            for (var i = 0; i < ImageInfos.Length; i++)
 2168            {
 2169                var imageInfo = ImageInfos[i];
 2170                if (imageInfo.Type == imageType)
 2171                {
 2172                    yield return imageInfo;
 2173                }
 2174            }
 2175        }
 2176
 2177        /// <summary>
 2178        /// Adds the images, updating metadata if they already are part of this item.
 2179        /// </summary>
 2180        /// <param name="imageType">Type of the image.</param>
 2181        /// <param name="images">The images.</param>
 2182        /// <returns><c>true</c> if images were added or updated, <c>false</c> otherwise.</returns>
 2183        /// <exception cref="ArgumentException">Cannot call AddImages with chapter images.</exception>
 2184        public bool AddImages(ImageType imageType, List<FileSystemMetadata> images)
 2185        {
 702186            if (imageType == ImageType.Chapter)
 2187            {
 02188                throw new ArgumentException("Cannot call AddImages with chapter images");
 2189            }
 2190
 702191            var existingImages = GetImages(imageType)
 702192                .ToList();
 2193
 702194            var newImageList = new List<FileSystemMetadata>();
 702195            var imageUpdated = false;
 2196
 1562197            foreach (var newImage in images)
 2198            {
 82199                if (newImage is null)
 2200                {
 02201                    throw new ArgumentException("null image found in list");
 2202                }
 2203
 82204                var existing = existingImages
 82205                    .Find(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase));
 2206
 82207                if (existing is null)
 2208                {
 42209                    newImageList.Add(newImage);
 2210                }
 2211                else
 2212                {
 42213                    if (existing.IsLocalFile)
 2214                    {
 42215                        var newDateModified = FileSystem.GetLastWriteTimeUtc(newImage);
 2216
 2217                        // If date changed then we need to reset saved image dimensions
 42218                        if (existing.DateModified != newDateModified && (existing.Width > 0 || existing.Height > 0))
 2219                        {
 22220                            existing.Width = 0;
 22221                            existing.Height = 0;
 22222                            imageUpdated = true;
 2223                        }
 2224
 42225                        existing.DateModified = newDateModified;
 2226                    }
 2227                }
 2228            }
 2229
 702230            if (newImageList.Count > 0)
 2231            {
 22232                ImageInfos = ImageInfos.Concat(newImageList.Select(i => GetImageInfo(i, imageType))).ToArray();
 2233            }
 2234
 702235            return imageUpdated || newImageList.Count > 0;
 2236        }
 2237
 2238        private ItemImageInfo GetImageInfo(FileSystemMetadata file, ImageType type)
 2239        {
 502240            return new ItemImageInfo
 502241            {
 502242                Path = file.FullName,
 502243                Type = type,
 502244                DateModified = FileSystem.GetLastWriteTimeUtc(file)
 502245            };
 2246        }
 2247
 2248        /// <summary>
 2249        /// Gets the file system path to delete when the item is to be deleted.
 2250        /// </summary>
 2251        /// <returns>The metadata for the deleted paths.</returns>
 2252        public virtual IEnumerable<FileSystemMetadata> GetDeletePaths()
 2253        {
 02254            return new[]
 02255            {
 02256                FileSystem.GetFileSystemInfo(Path)
 02257            }.Concat(GetLocalMetadataFilesToDelete());
 2258        }
 2259
 2260        protected List<FileSystemMetadata> GetLocalMetadataFilesToDelete()
 2261        {
 02262            if (IsFolder || !IsInMixedFolder)
 2263            {
 02264                return [];
 2265            }
 2266
 02267            var filename = System.IO.Path.GetFileNameWithoutExtension(Path);
 2268
 02269            return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), _supportedExtensions, false, false)
 02270                .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison
 02271                .ToList();
 2272        }
 2273
 2274        public bool AllowsMultipleImages(ImageType type)
 2275        {
 182276            return type == ImageType.Backdrop || type == ImageType.Chapter;
 2277        }
 2278
 2279        public Task SwapImagesAsync(ImageType type, int index1, int index2)
 2280        {
 02281            if (!AllowsMultipleImages(type))
 2282            {
 02283                throw new ArgumentException("The change index operation is only applicable to backdrops and screen shots
 2284            }
 2285
 02286            var info1 = GetImageInfo(type, index1);
 02287            var info2 = GetImageInfo(type, index2);
 2288
 02289            if (info1 is null || info2 is null)
 2290            {
 2291                // Nothing to do
 02292                return Task.CompletedTask;
 2293            }
 2294
 02295            if (!info1.IsLocalFile || !info2.IsLocalFile)
 2296            {
 2297                // TODO: Not supported  yet
 02298                return Task.CompletedTask;
 2299            }
 2300
 02301            var path1 = info1.Path;
 02302            var path2 = info2.Path;
 2303
 02304            FileSystem.SwapFiles(path1, path2);
 2305
 2306            // Refresh these values
 02307            info1.DateModified = FileSystem.GetLastWriteTimeUtc(info1.Path);
 02308            info2.DateModified = FileSystem.GetLastWriteTimeUtc(info2.Path);
 2309
 02310            info1.Width = 0;
 02311            info1.Height = 0;
 02312            info2.Width = 0;
 02313            info2.Height = 0;
 2314
 02315            return UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None);
 2316        }
 2317
 2318        public virtual bool IsPlayed(User user)
 2319        {
 02320            var userdata = UserDataManager.GetUserData(user, this);
 2321
 02322            return userdata is not null && userdata.Played;
 2323        }
 2324
 2325        public bool IsFavoriteOrLiked(User user)
 2326        {
 02327            var userdata = UserDataManager.GetUserData(user, this);
 2328
 02329            return userdata is not null && (userdata.IsFavorite || (userdata.Likes ?? false));
 2330        }
 2331
 2332        public virtual bool IsUnplayed(User user)
 2333        {
 02334            ArgumentNullException.ThrowIfNull(user);
 2335
 02336            var userdata = UserDataManager.GetUserData(user, this);
 2337
 02338            return userdata is null || !userdata.Played;
 2339        }
 2340
 2341        ItemLookupInfo IHasLookupInfo<ItemLookupInfo>.GetLookupInfo()
 2342        {
 562343            return GetItemLookupInfo<ItemLookupInfo>();
 2344        }
 2345
 2346        protected T GetItemLookupInfo<T>()
 2347            where T : ItemLookupInfo, new()
 2348        {
 562349            return new T
 562350            {
 562351                Path = Path,
 562352                MetadataCountryCode = GetPreferredMetadataCountryCode(),
 562353                MetadataLanguage = GetPreferredMetadataLanguage(),
 562354                Name = GetNameForMetadataLookup(),
 562355                OriginalTitle = OriginalTitle,
 562356                ProviderIds = ProviderIds,
 562357                IndexNumber = IndexNumber,
 562358                ParentIndexNumber = ParentIndexNumber,
 562359                Year = ProductionYear,
 562360                PremiereDate = PremiereDate
 562361            };
 2362        }
 2363
 2364        protected virtual string GetNameForMetadataLookup()
 2365        {
 562366            return Name;
 2367        }
 2368
 2369        /// <summary>
 2370        /// This is called before any metadata refresh and returns true if changes were made.
 2371        /// </summary>
 2372        /// <param name="replaceAllMetadata">Whether to replace all metadata.</param>
 2373        /// <returns>true if the item has change, else false.</returns>
 2374        public virtual bool BeforeMetadataRefresh(bool replaceAllMetadata)
 2375        {
 562376            _sortName = null;
 2377
 562378            var hasChanges = false;
 2379
 562380            if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path))
 2381            {
 02382                Name = System.IO.Path.GetFileNameWithoutExtension(Path);
 02383                hasChanges = true;
 2384            }
 2385
 562386            return hasChanges;
 2387        }
 2388
 2389        protected static string GetMappedPath(BaseItem item, string path, MediaProtocol? protocol)
 2390        {
 02391            if (protocol == MediaProtocol.File)
 2392            {
 02393                return LibraryManager.GetPathAfterNetworkSubstitution(path, item);
 2394            }
 2395
 02396            return path;
 2397        }
 2398
 2399        public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User 
 2400        {
 02401            if (RunTimeTicks.HasValue)
 2402            {
 02403                double pct = RunTimeTicks.Value;
 2404
 02405                if (pct > 0)
 2406                {
 02407                    pct = userData.PlaybackPositionTicks / pct;
 2408
 02409                    if (pct > 0)
 2410                    {
 02411                        dto.PlayedPercentage = 100 * pct;
 2412                    }
 2413                }
 2414            }
 02415        }
 2416
 2417        protected async Task RefreshMetadataForOwnedItem(BaseItem ownedItem, bool copyTitleMetadata, MetadataRefreshOpti
 2418        {
 2419            var newOptions = new MetadataRefreshOptions(options)
 2420            {
 2421                SearchResult = null
 2422            };
 2423
 2424            var item = this;
 2425
 2426            if (copyTitleMetadata)
 2427            {
 2428                // Take some data from the main item, for querying purposes
 2429                if (!item.Genres.SequenceEqual(ownedItem.Genres, StringComparer.Ordinal))
 2430                {
 2431                    newOptions.ForceSave = true;
 2432                    ownedItem.Genres = item.Genres;
 2433                }
 2434
 2435                if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal))
 2436                {
 2437                    newOptions.ForceSave = true;
 2438                    ownedItem.Studios = item.Studios;
 2439                }
 2440
 2441                if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal))
 2442                {
 2443                    newOptions.ForceSave = true;
 2444                    ownedItem.ProductionLocations = item.ProductionLocations;
 2445                }
 2446
 2447                if (item.CommunityRating != ownedItem.CommunityRating)
 2448                {
 2449                    ownedItem.CommunityRating = item.CommunityRating;
 2450                    newOptions.ForceSave = true;
 2451                }
 2452
 2453                if (item.CriticRating != ownedItem.CriticRating)
 2454                {
 2455                    ownedItem.CriticRating = item.CriticRating;
 2456                    newOptions.ForceSave = true;
 2457                }
 2458
 2459                if (!string.Equals(item.Overview, ownedItem.Overview, StringComparison.Ordinal))
 2460                {
 2461                    ownedItem.Overview = item.Overview;
 2462                    newOptions.ForceSave = true;
 2463                }
 2464
 2465                if (!string.Equals(item.OfficialRating, ownedItem.OfficialRating, StringComparison.Ordinal))
 2466                {
 2467                    ownedItem.OfficialRating = item.OfficialRating;
 2468                    newOptions.ForceSave = true;
 2469                }
 2470
 2471                if (!string.Equals(item.CustomRating, ownedItem.CustomRating, StringComparison.Ordinal))
 2472                {
 2473                    ownedItem.CustomRating = item.CustomRating;
 2474                    newOptions.ForceSave = true;
 2475                }
 2476            }
 2477
 2478            await ownedItem.RefreshMetadata(newOptions, cancellationToken).ConfigureAwait(false);
 2479        }
 2480
 2481        protected async Task RefreshMetadataForOwnedVideo(MetadataRefreshOptions options, bool copyTitleMetadata, string
 2482        {
 2483            var newOptions = new MetadataRefreshOptions(options)
 2484            {
 2485                SearchResult = null
 2486            };
 2487
 2488            var id = LibraryManager.GetNewItemId(path, typeof(Video));
 2489
 2490            // Try to retrieve it from the db. If we don't find it, use the resolved version
 2491            if (LibraryManager.GetItemById(id) is not Video video)
 2492            {
 2493                video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video;
 2494
 2495                newOptions.ForceSave = true;
 2496            }
 2497
 2498            if (video is null)
 2499            {
 2500                return;
 2501            }
 2502
 2503            if (video.OwnerId.IsEmpty())
 2504            {
 2505                video.OwnerId = Id;
 2506            }
 2507
 2508            await RefreshMetadataForOwnedItem(video, copyTitleMetadata, newOptions, cancellationToken).ConfigureAwait(fa
 2509        }
 2510
 2511        public string GetEtag(User user)
 2512        {
 62513            var list = GetEtagValues(user);
 2514
 62515            return string.Join('|', list).GetMD5().ToString("N", CultureInfo.InvariantCulture);
 2516        }
 2517
 2518        protected virtual List<string> GetEtagValues(User user)
 2519        {
 62520            return
 62521            [
 62522                DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture)
 62523            ];
 2524        }
 2525
 2526        public virtual IEnumerable<Guid> GetAncestorIds()
 2527        {
 922528            return GetParents().Select(i => i.Id).Concat(LibraryManager.GetCollectionFolders(this).Select(i => i.Id));
 2529        }
 2530
 2531        public BaseItem GetTopParent()
 2532        {
 922533            if (IsTopParent)
 2534            {
 212535                return this;
 2536            }
 2537
 712538            return GetParents().FirstOrDefault(parent => parent.IsTopParent);
 2539        }
 2540
 2541        public virtual IEnumerable<Guid> GetIdsForAncestorQuery()
 2542        {
 412543            return [Id];
 2544        }
 2545
 2546        public virtual double? GetRefreshProgress()
 2547        {
 02548            return null;
 2549        }
 2550
 2551        public virtual ItemUpdateType OnMetadataChanged()
 2552        {
 1122553            var updateType = ItemUpdateType.None;
 2554
 1122555            var item = this;
 2556
 1122557            var rating = item.GetParentalRatingScore();
 1122558            if (rating is not null)
 2559            {
 02560                if (rating.Score != item.InheritedParentalRatingValue)
 2561                {
 02562                    item.InheritedParentalRatingValue = rating.Score;
 02563                    updateType |= ItemUpdateType.MetadataImport;
 2564                }
 2565
 02566                if (rating.SubScore != item.InheritedParentalRatingSubValue)
 2567                {
 02568                    item.InheritedParentalRatingSubValue = rating.SubScore;
 02569                    updateType |= ItemUpdateType.MetadataImport;
 2570                }
 2571            }
 2572            else
 2573            {
 1122574                if (item.InheritedParentalRatingValue is not null)
 2575                {
 02576                    item.InheritedParentalRatingValue = null;
 02577                    item.InheritedParentalRatingSubValue = null;
 02578                    updateType |= ItemUpdateType.MetadataImport;
 2579                }
 2580            }
 2581
 1122582            return updateType;
 2583        }
 2584
 2585        /// <summary>
 2586        /// Updates the official rating based on content and returns true or false indicating if it changed.
 2587        /// </summary>
 2588        /// <param name="children">Media children.</param>
 2589        /// <returns><c>true</c> if the rating was updated; otherwise <c>false</c>.</returns>
 2590        public bool UpdateRatingToItems(IReadOnlyList<BaseItem> children)
 2591        {
 02592            var currentOfficialRating = OfficialRating;
 2593
 2594            // Gather all possible ratings
 02595            var ratings = children
 02596                .Select(i => i.OfficialRating)
 02597                .Where(i => !string.IsNullOrEmpty(i))
 02598                .Distinct(StringComparer.OrdinalIgnoreCase)
 02599                .Select(rating => (rating, LocalizationManager.GetRatingScore(rating)))
 02600                .OrderBy(i => i.Item2 is null ? 1001 : i.Item2.Score)
 02601                .ThenBy(i => i.Item2 is null ? 1001 : i.Item2.SubScore)
 02602                .Select(i => i.rating);
 2603
 02604            OfficialRating = ratings.FirstOrDefault() ?? currentOfficialRating;
 2605
 02606            return !string.Equals(
 02607                currentOfficialRating ?? string.Empty,
 02608                OfficialRating ?? string.Empty,
 02609                StringComparison.OrdinalIgnoreCase);
 2610        }
 2611
 2612        public IReadOnlyList<BaseItem> GetThemeSongs(User user = null)
 2613        {
 02614            return GetThemeSongs(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2615        }
 2616
 2617        public IReadOnlyList<BaseItem> GetThemeSongs(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> or
 2618        {
 02619            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeSong), user, 
 2620        }
 2621
 2622        public IReadOnlyList<BaseItem> GetThemeVideos(User user = null)
 2623        {
 02624            return GetThemeVideos(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2625        }
 2626
 2627        public IReadOnlyList<BaseItem> GetThemeVideos(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> o
 2628        {
 02629            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeVideo), user,
 2630        }
 2631
 2632        /// <summary>
 2633        /// Get all extras associated with this item, sorted by <see cref="SortName"/>.
 2634        /// </summary>
 2635        /// <returns>An enumerable containing the items.</returns>
 2636        public IEnumerable<BaseItem> GetExtras()
 2637        {
 62638            return ExtraIds
 62639                .Select(LibraryManager.GetItemById)
 62640                .Where(i => i is not null)
 62641                .OrderBy(i => i.SortName);
 2642        }
 2643
 2644        /// <summary>
 2645        /// Get all extras with specific types that are associated with this item.
 2646        /// </summary>
 2647        /// <param name="extraTypes">The types of extras to retrieve.</param>
 2648        /// <returns>An enumerable containing the extras.</returns>
 2649        public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
 2650        {
 02651            return ExtraIds
 02652                .Select(LibraryManager.GetItemById)
 02653                .Where(i => i is not null)
 02654                .Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value))
 02655                .OrderBy(i => i.SortName);
 2656        }
 2657
 2658        public virtual long GetRunTimeTicksForPlayState()
 2659        {
 02660            return RunTimeTicks ?? 0;
 2661        }
 2662
 2663        /// <inheritdoc />
 2664        public override bool Equals(object obj)
 2665        {
 02666            return obj is BaseItem baseItem && this.Equals(baseItem);
 2667        }
 2668
 2669        /// <inheritdoc />
 62670        public bool Equals(BaseItem other) => other is not null && other.Id.Equals(Id);
 2671
 2672        /// <inheritdoc />
 552673        public override int GetHashCode() => HashCode.Combine(Id);
 2674    }
 2675}

Methods/Properties

.cctor()
.ctor()
get_SupportsAddingToPlaylist()
get_AlwaysScanInternalMetadataPath()
get_SupportsPlayedStatus()
get_SupportsPositionTicksResume()
get_SupportsRemoteImageDownloading()
get_Name()
set_Name(System.String)
get_IsUnaired()
get_IsThemeMedia()
get_DisplayPreferencesId()
get_SourceType()
get_ContainingFolderPath()
get_IsHidden()
get_LocationType()
get_PathProtocol()
get_IsFileProtocol()
get_HasPathProtocol()
get_SupportsLocalMetadata()
get_FileNameWithoutExtension()
get_EnableAlphaNumericSorting()
get_IsHD()
get_PrimaryImagePath()
get_MediaType()
get_PhysicalLocations()
get_EnableMediaSourceDisplay()
get_ForcedSortName()
set_ForcedSortName(System.String)
get_SortName()
set_SortName(System.String)
get_DisplayParentId()
get_DisplayParent()
get_HasLocalAlternateVersions()
get_OfficialRatingForComparison()
get_CustomRatingForComparison()
get_LatestItemsIndexContainer()
get_EnableRememberingTrackSelections()
get_IsTopParent()
get_SupportsAncestors()
get_SupportsOwnedItems()
get_SupportsPeople()
get_SupportsThemeMedia()
get_SupportsInheritedParentImages()
get_IsFolder()
get_IsDisplayedAsFolder()
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()