< 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: 377
Uncovered lines: 353
Coverable lines: 730
Total lines: 2682
Line coverage: 51.6%
Branch coverage
41%
Covered branches: 189
Total branches: 458
Branch coverage: 41.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

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

File(s)

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

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591, SA1401
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Collections.Immutable;
 8using System.Globalization;
 9using System.IO;
 10using System.Linq;
 11using System.Text;
 12using System.Text.Json.Serialization;
 13using System.Threading;
 14using System.Threading.Tasks;
 15using Jellyfin.Data;
 16using Jellyfin.Data.Enums;
 17using Jellyfin.Database.Implementations.Entities;
 18using Jellyfin.Database.Implementations.Enums;
 19using Jellyfin.Extensions;
 20using MediaBrowser.Common.Extensions;
 21using MediaBrowser.Controller.Channels;
 22using MediaBrowser.Controller.Chapters;
 23using MediaBrowser.Controller.Configuration;
 24using MediaBrowser.Controller.Dto;
 25using MediaBrowser.Controller.Entities.Audio;
 26using MediaBrowser.Controller.Entities.TV;
 27using MediaBrowser.Controller.Library;
 28using MediaBrowser.Controller.MediaSegments;
 29using MediaBrowser.Controller.Persistence;
 30using MediaBrowser.Controller.Providers;
 31using MediaBrowser.Model.Dto;
 32using MediaBrowser.Model.Entities;
 33using MediaBrowser.Model.Globalization;
 34using MediaBrowser.Model.IO;
 35using MediaBrowser.Model.Library;
 36using MediaBrowser.Model.LiveTv;
 37using MediaBrowser.Model.MediaInfo;
 38using Microsoft.Extensions.Logging;
 39
 40namespace MediaBrowser.Controller.Entities
 41{
 42    /// <summary>
 43    /// Class BaseItem.
 44    /// </summary>
 45    public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo>, IEquatable<BaseItem>
 46    {
 47        private BaseItemKind? _baseItemKind;
 48
 49        public const string ThemeSongFileName = "theme";
 50
 51        /// <summary>
 52        /// The supported image extensions.
 53        /// </summary>
 454        public static readonly string[] SupportedImageExtensions
 455            = [".png", ".jpg", ".jpeg", ".webp", ".tbn", ".gif", ".svg"];
 56
 457        private static readonly List<string> _supportedExtensions = new List<string>(SupportedImageExtensions)
 458        {
 459            ".nfo",
 460            ".xml",
 461            ".srt",
 462            ".vtt",
 463            ".sub",
 464            ".sup",
 465            ".idx",
 466            ".txt",
 467            ".edl",
 468            ".bif",
 469            ".smi",
 470            ".ttml",
 471            ".lrc",
 472            ".elrc"
 473        };
 74
 75        /// <summary>
 76        /// Extra types that should be counted and displayed as "Special Features" in the UI.
 77        /// </summary>
 478        public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new HashSet<ExtraType>
 479        {
 480            Model.Entities.ExtraType.Unknown,
 481            Model.Entities.ExtraType.BehindTheScenes,
 482            Model.Entities.ExtraType.Clip,
 483            Model.Entities.ExtraType.DeletedScene,
 484            Model.Entities.ExtraType.Interview,
 485            Model.Entities.ExtraType.Sample,
 486            Model.Entities.ExtraType.Scene,
 487            Model.Entities.ExtraType.Featurette,
 488            Model.Entities.ExtraType.Short
 489        };
 90
 91        private string _sortName;
 92
 93        private string _forcedSortName;
 94
 95        private string _name;
 96
 97        public const char SlugChar = '-';
 98
 99        protected BaseItem()
 100        {
 941101            Tags = Array.Empty<string>();
 941102            Genres = Array.Empty<string>();
 941103            Studios = Array.Empty<string>();
 941104            ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 941105            LockedFields = Array.Empty<MetadataField>();
 941106            ImageInfos = Array.Empty<ItemImageInfo>();
 941107            ProductionLocations = Array.Empty<string>();
 941108            RemoteTrailers = Array.Empty<MediaUrl>();
 941109            ExtraIds = Array.Empty<Guid>();
 941110            UserData = [];
 941111        }
 112
 113        /// <summary>
 114        /// Gets or Sets the user data collection as cached from the last Db query.
 115        /// </summary>
 116        [JsonIgnore]
 117        public ICollection<UserData> UserData { get; set; }
 118
 119        [JsonIgnore]
 120        public string PreferredMetadataCountryCode { get; set; }
 121
 122        [JsonIgnore]
 123        public string PreferredMetadataLanguage { get; set; }
 124
 125        public long? Size { get; set; }
 126
 127        public string Container { get; set; }
 128
 129        [JsonIgnore]
 130        public string Tagline { get; set; }
 131
 132        [JsonIgnore]
 133        public virtual ItemImageInfo[] ImageInfos { get; set; }
 134
 135        [JsonIgnore]
 136        public bool IsVirtualItem { get; set; }
 137
 138        /// <summary>
 139        /// Gets or sets the album.
 140        /// </summary>
 141        /// <value>The album.</value>
 142        [JsonIgnore]
 143        public string Album { get; set; }
 144
 145        /// <summary>
 146        /// Gets or sets the LUFS value.
 147        /// </summary>
 148        /// <value>The LUFS Value.</value>
 149        [JsonIgnore]
 150        public float? LUFS { get; set; }
 151
 152        /// <summary>
 153        /// Gets or sets the gain required for audio normalization.
 154        /// </summary>
 155        /// <value>The gain required for audio normalization.</value>
 156        [JsonIgnore]
 157        public float? NormalizationGain { get; set; }
 158
 159        /// <summary>
 160        /// Gets or sets the channel identifier.
 161        /// </summary>
 162        /// <value>The channel identifier.</value>
 163        [JsonIgnore]
 164        public Guid ChannelId { get; set; }
 165
 166        [JsonIgnore]
 0167        public virtual bool SupportsAddingToPlaylist => false;
 168
 169        [JsonIgnore]
 12170        public virtual bool AlwaysScanInternalMetadataPath => false;
 171
 172        /// <summary>
 173        /// Gets or sets a value indicating whether this instance is in mixed folder.
 174        /// </summary>
 175        /// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
 176        [JsonIgnore]
 177        public bool IsInMixedFolder { get; set; }
 178
 179        [JsonIgnore]
 0180        public virtual bool SupportsPlayedStatus => false;
 181
 182        [JsonIgnore]
 0183        public virtual bool SupportsPositionTicksResume => false;
 184
 185        [JsonIgnore]
 17186        public virtual bool SupportsRemoteImageDownloading => true;
 187
 188        /// <summary>
 189        /// Gets or sets the name.
 190        /// </summary>
 191        /// <value>The name.</value>
 192        [JsonIgnore]
 193        public virtual string Name
 194        {
 1015195            get => _name;
 196            set
 197            {
 299198                _name = value;
 199
 200                // lazy load this again
 299201                _sortName = null;
 299202            }
 203        }
 204
 205        [JsonIgnore]
 0206        public bool IsUnaired => PremiereDate.HasValue && PremiereDate.Value.ToLocalTime().Date >= DateTime.Now.Date;
 207
 208        [JsonIgnore]
 209        public int? TotalBitrate { get; set; }
 210
 211        [JsonIgnore]
 212        public ExtraType? ExtraType { get; set; }
 213
 214        [JsonIgnore]
 0215        public bool IsThemeMedia => ExtraType.HasValue && (ExtraType.Value == Model.Entities.ExtraType.ThemeSong || Extr
 216
 217        [JsonIgnore]
 218        public string OriginalTitle { get; set; }
 219
 220        /// <summary>
 221        /// Gets or sets the id.
 222        /// </summary>
 223        /// <value>The id.</value>
 224        [JsonIgnore]
 225        public Guid Id { get; set; }
 226
 227        [JsonIgnore]
 228        public Guid OwnerId { get; set; }
 229
 230        /// <summary>
 231        /// Gets or sets the audio.
 232        /// </summary>
 233        /// <value>The audio.</value>
 234        [JsonIgnore]
 235        public ProgramAudio? Audio { get; set; }
 236
 237        /// <summary>
 238        /// Gets the id that should be used to key display prefs for this item.
 239        /// Default is based on the type for everything except actual generic folders.
 240        /// </summary>
 241        /// <value>The display prefs id.</value>
 242        [JsonIgnore]
 243        public virtual Guid DisplayPreferencesId
 244        {
 245            get
 246            {
 6247                var thisType = GetType();
 6248                return thisType == typeof(Folder) ? Id : thisType.FullName.GetMD5();
 249            }
 250        }
 251
 252        /// <summary>
 253        /// Gets or sets the path.
 254        /// </summary>
 255        /// <value>The path.</value>
 256        [JsonIgnore]
 257        public virtual string Path { get; set; }
 258
 259        [JsonIgnore]
 260        public virtual SourceType SourceType
 261        {
 262            get
 263            {
 2229264                if (!ChannelId.IsEmpty())
 265                {
 0266                    return SourceType.Channel;
 267                }
 268
 2229269                return SourceType.Library;
 270            }
 271        }
 272
 273        /// <summary>
 274        /// Gets the folder containing the item.
 275        /// If the item is a folder, it returns the folder itself.
 276        /// </summary>
 277        [JsonIgnore]
 278        public virtual string ContainingFolderPath
 279        {
 280            get
 281            {
 428282                if (IsFolder)
 283                {
 377284                    return Path;
 285                }
 286
 51287                return System.IO.Path.GetDirectoryName(Path);
 288            }
 289        }
 290
 291        /// <summary>
 292        /// Gets or sets the name of the service.
 293        /// </summary>
 294        /// <value>The name of the service.</value>
 295        [JsonIgnore]
 296        public string ServiceName { get; set; }
 297
 298        /// <summary>
 299        /// Gets or sets the external id.
 300        /// </summary>
 301        /// <remarks>
 302        /// If this content came from an external service, the id of the content on that service.
 303        /// </remarks>
 304        [JsonIgnore]
 305        public string ExternalId { get; set; }
 306
 307        [JsonIgnore]
 308        public string ExternalSeriesId { get; set; }
 309
 310        [JsonIgnore]
 0311        public virtual bool IsHidden => false;
 312
 313        /// <summary>
 314        /// Gets the type of the location.
 315        /// </summary>
 316        /// <value>The type of the location.</value>
 317        [JsonIgnore]
 318        public virtual LocationType LocationType
 319        {
 320            get
 321            {
 9322                var path = Path;
 9323                if (string.IsNullOrEmpty(path))
 324                {
 0325                    if (SourceType == SourceType.Channel)
 326                    {
 0327                        return LocationType.Remote;
 328                    }
 329
 0330                    return LocationType.Virtual;
 331                }
 332
 9333                return FileSystem.IsPathFile(path) ? LocationType.FileSystem : LocationType.Remote;
 334            }
 335        }
 336
 337        [JsonIgnore]
 338        public MediaProtocol? PathProtocol
 339        {
 340            get
 341            {
 2665342                var path = Path;
 343
 2665344                if (string.IsNullOrEmpty(path))
 345                {
 116346                    return null;
 347                }
 348
 2549349                return MediaSourceManager.GetPathProtocol(path);
 350            }
 351        }
 352
 353        [JsonIgnore]
 2644354        public bool IsFileProtocol => PathProtocol == MediaProtocol.File;
 355
 356        [JsonIgnore]
 0357        public bool HasPathProtocol => PathProtocol.HasValue;
 358
 359        [JsonIgnore]
 360        public virtual bool SupportsLocalMetadata
 361        {
 362            get
 363            {
 1470364                if (SourceType == SourceType.Channel)
 365                {
 0366                    return false;
 367                }
 368
 1470369                return IsFileProtocol;
 370            }
 371        }
 372
 373        [JsonIgnore]
 374        public virtual string FileNameWithoutExtension
 375        {
 376            get
 377            {
 0378                if (IsFileProtocol)
 379                {
 0380                    return System.IO.Path.GetFileNameWithoutExtension(Path);
 381                }
 382
 0383                return null;
 384            }
 385        }
 386
 387        [JsonIgnore]
 103388        public virtual bool EnableAlphaNumericSorting => true;
 389
 133390        public virtual bool IsHD => Height >= 720;
 391
 392        public bool IsShortcut { get; set; }
 393
 394        public string ShortcutPath { get; set; }
 395
 396        public int Width { get; set; }
 397
 398        public int Height { get; set; }
 399
 400        public Guid[] ExtraIds { get; set; }
 401
 402        /// <summary>
 403        /// Gets the primary image path.
 404        /// </summary>
 405        /// <remarks>
 406        /// This is just a helper for convenience.
 407        /// </remarks>
 408        /// <value>The primary image path.</value>
 409        [JsonIgnore]
 0410        public string PrimaryImagePath => this.GetImagePath(ImageType.Primary);
 411
 412        /// <summary>
 413        /// Gets or sets the date created.
 414        /// </summary>
 415        /// <value>The date created.</value>
 416        [JsonIgnore]
 417        public DateTime DateCreated { get; set; }
 418
 419        /// <summary>
 420        /// Gets or sets the date modified.
 421        /// </summary>
 422        /// <value>The date modified.</value>
 423        [JsonIgnore]
 424        public DateTime DateModified { get; set; }
 425
 426        public DateTime DateLastSaved { get; set; }
 427
 428        [JsonIgnore]
 429        public DateTime DateLastRefreshed { get; set; }
 430
 431        [JsonIgnore]
 432        public bool IsLocked { get; set; }
 433
 434        /// <summary>
 435        /// Gets or sets the locked fields.
 436        /// </summary>
 437        /// <value>The locked fields.</value>
 438        [JsonIgnore]
 439        public MetadataField[] LockedFields { get; set; }
 440
 441        /// <summary>
 442        /// Gets the type of the media.
 443        /// </summary>
 444        /// <value>The type of the media.</value>
 445        [JsonIgnore]
 123446        public virtual MediaType MediaType => MediaType.Unknown;
 447
 448        [JsonIgnore]
 449        public virtual string[] PhysicalLocations
 450        {
 451            get
 452            {
 0453                if (!IsFileProtocol)
 454                {
 0455                    return Array.Empty<string>();
 456                }
 457
 0458                return [Path];
 459            }
 460        }
 461
 462        [JsonIgnore]
 463        public bool EnableMediaSourceDisplay
 464        {
 465            get
 466            {
 6467                if (SourceType == SourceType.Channel)
 468                {
 0469                    return ChannelManager.EnableMediaSourceDisplay(this);
 470                }
 471
 6472                return true;
 473            }
 474        }
 475
 476        [JsonIgnore]
 477        public Guid ParentId { get; set; }
 478
 479        /// <summary>
 480        /// Gets or sets the logger.
 481        /// </summary>
 482        public static ILogger<BaseItem> Logger { get; set; }
 483
 484        public static ILibraryManager LibraryManager { get; set; }
 485
 486        public static IServerConfigurationManager ConfigurationManager { get; set; }
 487
 488        public static IProviderManager ProviderManager { get; set; }
 489
 490        public static ILocalizationManager LocalizationManager { get; set; }
 491
 492        public static IItemRepository ItemRepository { get; set; }
 493
 494        public static IChapterManager ChapterManager { get; set; }
 495
 496        public static IFileSystem FileSystem { get; set; }
 497
 498        public static IUserDataManager UserDataManager { get; set; }
 499
 500        public static IChannelManager ChannelManager { get; set; }
 501
 502        public static IMediaSourceManager MediaSourceManager { get; set; }
 503
 504        public static IMediaSegmentManager MediaSegmentManager { get; set; }
 505
 506        /// <summary>
 507        /// Gets or sets the name of the forced sort.
 508        /// </summary>
 509        /// <value>The name of the forced sort.</value>
 510        [JsonIgnore]
 511        public string ForcedSortName
 512        {
 468513            get => _forcedSortName;
 514            set
 515            {
 66516                _forcedSortName = value;
 66517                _sortName = null;
 66518            }
 519        }
 520
 521        /// <summary>
 522        /// Gets or sets the name of the sort.
 523        /// </summary>
 524        /// <value>The name of the sort.</value>
 525        [JsonIgnore]
 526        public string SortName
 527        {
 528            get
 529            {
 163530                if (_sortName is null)
 531                {
 103532                    if (!string.IsNullOrEmpty(ForcedSortName))
 533                    {
 534                        // Need the ToLower because that's what CreateSortName does
 0535                        _sortName = ModifySortChunks(ForcedSortName).ToLowerInvariant();
 536                    }
 537                    else
 538                    {
 103539                        _sortName = CreateSortName();
 540                    }
 541                }
 542
 163543                return _sortName;
 544            }
 545
 95546            set => _sortName = value;
 547        }
 548
 549        [JsonIgnore]
 326550        public virtual Guid DisplayParentId => ParentId;
 551
 552        [JsonIgnore]
 553        public BaseItem DisplayParent
 554        {
 555            get
 556            {
 320557                var id = DisplayParentId;
 320558                if (id.IsEmpty())
 559                {
 246560                    return null;
 561                }
 562
 74563                return LibraryManager.GetItemById(id);
 564            }
 565        }
 566
 567        /// <summary>
 568        /// Gets or sets the date that the item first debuted. For movies this could be premiere date, episodes would be
 569        /// </summary>
 570        /// <value>The premiere date.</value>
 571        [JsonIgnore]
 572        public DateTime? PremiereDate { get; set; }
 573
 574        /// <summary>
 575        /// Gets or sets the end date.
 576        /// </summary>
 577        /// <value>The end date.</value>
 578        [JsonIgnore]
 579        public DateTime? EndDate { get; set; }
 580
 581        /// <summary>
 582        /// Gets or sets the official rating.
 583        /// </summary>
 584        /// <value>The official rating.</value>
 585        [JsonIgnore]
 586        public string OfficialRating { get; set; }
 587
 588        [JsonIgnore]
 589        public int? InheritedParentalRatingValue { get; set; }
 590
 591        [JsonIgnore]
 592        public int? InheritedParentalRatingSubValue { get; set; }
 593
 594        /// <summary>
 595        /// Gets or sets the critic rating.
 596        /// </summary>
 597        /// <value>The critic rating.</value>
 598        [JsonIgnore]
 599        public float? CriticRating { get; set; }
 600
 601        /// <summary>
 602        /// Gets or sets the custom rating.
 603        /// </summary>
 604        /// <value>The custom rating.</value>
 605        [JsonIgnore]
 606        public string CustomRating { get; set; }
 607
 608        /// <summary>
 609        /// Gets or sets the overview.
 610        /// </summary>
 611        /// <value>The overview.</value>
 612        [JsonIgnore]
 613        public string Overview { get; set; }
 614
 615        /// <summary>
 616        /// Gets or sets the studios.
 617        /// </summary>
 618        /// <value>The studios.</value>
 619        [JsonIgnore]
 620        public string[] Studios { get; set; }
 621
 622        /// <summary>
 623        /// Gets or sets the genres.
 624        /// </summary>
 625        /// <value>The genres.</value>
 626        [JsonIgnore]
 627        public string[] Genres { get; set; }
 628
 629        /// <summary>
 630        /// Gets or sets the tags.
 631        /// </summary>
 632        /// <value>The tags.</value>
 633        [JsonIgnore]
 634        public string[] Tags { get; set; }
 635
 636        [JsonIgnore]
 637        public string[] ProductionLocations { get; set; }
 638
 639        /// <summary>
 640        /// Gets or sets the home page URL.
 641        /// </summary>
 642        /// <value>The home page URL.</value>
 643        [JsonIgnore]
 644        public string HomePageUrl { get; set; }
 645
 646        /// <summary>
 647        /// Gets or sets the community rating.
 648        /// </summary>
 649        /// <value>The community rating.</value>
 650        [JsonIgnore]
 651        public float? CommunityRating { get; set; }
 652
 653        /// <summary>
 654        /// Gets or sets the run time ticks.
 655        /// </summary>
 656        /// <value>The run time ticks.</value>
 657        [JsonIgnore]
 658        public long? RunTimeTicks { get; set; }
 659
 660        /// <summary>
 661        /// Gets or sets the production year.
 662        /// </summary>
 663        /// <value>The production year.</value>
 664        [JsonIgnore]
 665        public int? ProductionYear { get; set; }
 666
 667        /// <summary>
 668        /// Gets or sets the index number. If the item is part of a series, this is it's number in the series.
 669        /// This could be episode number, album track number, etc.
 670        /// </summary>
 671        /// <value>The index number.</value>
 672        [JsonIgnore]
 673        public int? IndexNumber { get; set; }
 674
 675        /// <summary>
 676        /// Gets or sets the parent index number. For an episode this could be the season number, or for a song this cou
 677        /// </summary>
 678        /// <value>The parent index number.</value>
 679        [JsonIgnore]
 680        public int? ParentIndexNumber { get; set; }
 681
 682        [JsonIgnore]
 0683        public virtual bool HasLocalAlternateVersions => false;
 684
 685        [JsonIgnore]
 686        public string OfficialRatingForComparison
 687        {
 688            get
 689            {
 160690                var officialRating = OfficialRating;
 160691                if (!string.IsNullOrEmpty(officialRating))
 692                {
 0693                    return officialRating;
 694                }
 695
 160696                var parent = DisplayParent;
 160697                if (parent is not null)
 698                {
 37699                    return parent.OfficialRatingForComparison;
 700                }
 701
 123702                return null;
 703            }
 704        }
 705
 706        [JsonIgnore]
 707        public string CustomRatingForComparison
 708        {
 709            get
 710            {
 123711                return GetCustomRatingForComparision();
 712            }
 713        }
 714
 715        /// <summary>
 716        /// Gets or sets the provider ids.
 717        /// </summary>
 718        /// <value>The provider ids.</value>
 719        [JsonIgnore]
 720        public Dictionary<string, string> ProviderIds { get; set; }
 721
 722        [JsonIgnore]
 0723        public virtual Folder LatestItemsIndexContainer => null;
 724
 725        [JsonIgnore]
 726        public string PresentationUniqueKey { get; set; }
 727
 728        [JsonIgnore]
 0729        public virtual bool EnableRememberingTrackSelections => true;
 730
 731        [JsonIgnore]
 732        public virtual bool IsTopParent
 733        {
 734            get
 735            {
 280736                if (this is BasePluginFolder || this is Channel)
 737                {
 59738                    return true;
 739                }
 740
 221741                if (this is IHasCollectionType view)
 742                {
 14743                    if (view.CollectionType == CollectionType.livetv)
 744                    {
 0745                        return true;
 746                    }
 747                }
 748
 221749                if (GetParent() is AggregateFolder)
 750                {
 0751                    return true;
 752                }
 753
 221754                return false;
 755            }
 756        }
 757
 758        [JsonIgnore]
 228759        public virtual bool SupportsAncestors => true;
 760
 761        [JsonIgnore]
 90762        protected virtual bool SupportsOwnedItems => !ParentId.IsEmpty() && IsFileProtocol;
 763
 764        [JsonIgnore]
 72765        public virtual bool SupportsPeople => false;
 766
 767        [JsonIgnore]
 0768        public virtual bool SupportsThemeMedia => false;
 769
 770        [JsonIgnore]
 0771        public virtual bool SupportsInheritedParentImages => false;
 772
 773        /// <summary>
 774        /// Gets a value indicating whether this instance is folder.
 775        /// </summary>
 776        /// <value><c>true</c> if this instance is folder; otherwise, <c>false</c>.</value>
 777        [JsonIgnore]
 71778        public virtual bool IsFolder => false;
 779
 780        [JsonIgnore]
 0781        public virtual bool IsDisplayedAsFolder => false;
 782
 783        /// <summary>
 784        /// Gets or sets the remote trailers.
 785        /// </summary>
 786        /// <value>The remote trailers.</value>
 787        public IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
 788
 789        private string GetCustomRatingForComparision(HashSet<Guid> callstack = null)
 790        {
 160791            callstack ??= new();
 160792            var customRating = CustomRating;
 160793            if (!string.IsNullOrEmpty(customRating))
 794            {
 0795                return customRating;
 796            }
 797
 160798            callstack.Add(Id);
 799
 160800            var parent = DisplayParent;
 160801            if (parent is not null && !callstack.Contains(parent.Id))
 802            {
 37803                return parent.GetCustomRatingForComparision(callstack);
 804            }
 805
 123806            return null;
 807        }
 808
 809        public virtual double GetDefaultPrimaryImageAspectRatio()
 810        {
 0811            return 0;
 812        }
 813
 814        public virtual string CreatePresentationUniqueKey()
 815        {
 55816            return Id.ToString("N", CultureInfo.InvariantCulture);
 817        }
 818
 819        public virtual bool CanDelete()
 820        {
 0821            if (SourceType == SourceType.Channel)
 822            {
 0823                return ChannelManager.CanDelete(this);
 824            }
 825
 0826            return IsFileProtocol;
 827        }
 828
 829        public virtual bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
 830        {
 0831            if (user.HasPermission(PermissionKind.EnableContentDeletion))
 832            {
 0833                return true;
 834            }
 835
 0836            var allowed = user.GetPreferenceValues<Guid>(PreferenceKind.EnableContentDeletionFromFolders);
 837
 0838            if (SourceType == SourceType.Channel)
 839            {
 0840                return allowed.Contains(ChannelId);
 841            }
 842
 0843            var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
 844
 0845            foreach (var folder in collectionFolders)
 846            {
 0847                if (allowed.Contains(folder.Id))
 848                {
 0849                    return true;
 850                }
 851            }
 852
 0853            return false;
 0854        }
 855
 856        public BaseItem GetOwner()
 857        {
 700858            var ownerId = OwnerId;
 700859            return ownerId.IsEmpty() ? null : LibraryManager.GetItemById(ownerId);
 860        }
 861
 862        public bool CanDelete(User user, List<Folder> allCollectionFolders)
 863        {
 6864            return CanDelete() && IsAuthorizedToDelete(user, allCollectionFolders);
 865        }
 866
 867        public virtual bool CanDelete(User user)
 868        {
 6869            var allCollectionFolders = LibraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
 870
 6871            return CanDelete(user, allCollectionFolders);
 872        }
 873
 874        public virtual bool CanDownload()
 875        {
 6876            return false;
 877        }
 878
 879        public virtual bool IsAuthorizedToDownload(User user)
 880        {
 0881            return user.HasPermission(PermissionKind.EnableContentDownloading);
 882        }
 883
 884        public bool CanDownload(User user)
 885        {
 6886            return CanDownload() && IsAuthorizedToDownload(user);
 887        }
 888
 889        /// <inheritdoc />
 890        public override string ToString()
 891        {
 69892            return Name;
 893        }
 894
 895        public virtual string GetInternalMetadataPath()
 896        {
 71897            var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath;
 898
 71899            return GetInternalMetadataPath(basePath);
 900        }
 901
 902        protected virtual string GetInternalMetadataPath(string basePath)
 903        {
 71904            if (SourceType == SourceType.Channel)
 905            {
 0906                return System.IO.Path.Join(basePath, "channels", ChannelId.ToString("N", CultureInfo.InvariantCulture), 
 907            }
 908
 71909            ReadOnlySpan<char> idString = Id.ToString("N", CultureInfo.InvariantCulture);
 910
 71911            return System.IO.Path.Join(basePath, "library", idString[..2], idString);
 912        }
 913
 914        /// <summary>
 915        /// Creates the name of the sort.
 916        /// </summary>
 917        /// <returns>System.String.</returns>
 918        protected virtual string CreateSortName()
 919        {
 103920            if (Name is null)
 921            {
 0922                return null; // some items may not have name filled in properly
 923            }
 924
 103925            if (!EnableAlphaNumericSorting)
 926            {
 0927                return Name.TrimStart();
 928            }
 929
 103930            var sortable = Name.Trim().ToLowerInvariant();
 931
 824932            foreach (var search in ConfigurationManager.Configuration.SortRemoveWords)
 933            {
 934                // Remove from beginning if a space follows
 309935                if (sortable.StartsWith(search + " ", StringComparison.Ordinal))
 936                {
 0937                    sortable = sortable.Remove(0, search.Length + 1);
 938                }
 939
 940                // Remove from middle if surrounded by spaces
 309941                sortable = sortable.Replace(" " + search + " ", " ", StringComparison.Ordinal);
 942
 943                // Remove from end if preceeded by a space
 309944                if (sortable.EndsWith(" " + search, StringComparison.Ordinal))
 945                {
 0946                    sortable = sortable.Remove(sortable.Length - (search.Length + 1));
 947                }
 948            }
 949
 1442950            foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters)
 951            {
 618952                sortable = sortable.Replace(removeChar, string.Empty, StringComparison.Ordinal);
 953            }
 954
 824955            foreach (var replaceChar in ConfigurationManager.Configuration.SortReplaceCharacters)
 956            {
 309957                sortable = sortable.Replace(replaceChar, " ", StringComparison.Ordinal);
 958            }
 959
 103960            return ModifySortChunks(sortable);
 961        }
 962
 963        internal static string ModifySortChunks(ReadOnlySpan<char> name)
 964        {
 965            static void AppendChunk(StringBuilder builder, bool isDigitChunk, ReadOnlySpan<char> chunk)
 966            {
 967                if (isDigitChunk && chunk.Length < 10)
 968                {
 969                    builder.Append('0', 10 - chunk.Length);
 970                }
 971
 972                builder.Append(chunk);
 973            }
 974
 109975            if (name.IsEmpty)
 976            {
 1977                return string.Empty;
 978            }
 979
 108980            var builder = new StringBuilder(name.Length);
 981
 108982            int chunkStart = 0;
 108983            bool isDigitChunk = char.IsDigit(name[0]);
 1740984            for (int i = 0; i < name.Length; i++)
 985            {
 762986                var isDigit = char.IsDigit(name[i]);
 762987                if (isDigit != isDigitChunk)
 988                {
 5989                    AppendChunk(builder, isDigitChunk, name.Slice(chunkStart, i - chunkStart));
 5990                    chunkStart = i;
 5991                    isDigitChunk = isDigit;
 992                }
 993            }
 994
 108995            AppendChunk(builder, isDigitChunk, name.Slice(chunkStart));
 996
 997            // logger.LogDebug("ModifySortChunks Start: {0} End: {1}", name, builder.ToString());
 108998            var result = builder.ToString().RemoveDiacritics();
 108999            if (!result.All(char.IsAscii))
 1000            {
 01001                result = result.Transliterated();
 1002            }
 1003
 1081004            return result;
 1005        }
 1006
 1007        public BaseItem GetParent()
 1008        {
 19591009            var parentId = ParentId;
 19591010            if (parentId.IsEmpty())
 1011            {
 16471012                return null;
 1013            }
 1014
 3121015            return LibraryManager.GetItemById(parentId);
 1016        }
 1017
 1018        public IEnumerable<BaseItem> GetParents()
 1019        {
 1020            var parent = GetParent();
 1021
 1022            while (parent is not null)
 1023            {
 1024                yield return parent;
 1025
 1026                parent = parent.GetParent();
 1027            }
 1028        }
 1029
 1030        /// <summary>
 1031        /// Finds a parent of a given type.
 1032        /// </summary>
 1033        /// <typeparam name="T">Type of parent.</typeparam>
 1034        /// <returns>``0.</returns>
 1035        public T FindParent<T>()
 1036            where T : Folder
 1037        {
 01038            foreach (var parent in GetParents())
 1039            {
 01040                if (parent is T item)
 1041                {
 01042                    return item;
 1043                }
 1044            }
 1045
 01046            return null;
 01047        }
 1048
 1049        /// <summary>
 1050        /// Gets the play access.
 1051        /// </summary>
 1052        /// <param name="user">The user.</param>
 1053        /// <returns>PlayAccess.</returns>
 1054        public PlayAccess GetPlayAccess(User user)
 1055        {
 61056            if (!user.HasPermission(PermissionKind.EnableMediaPlayback))
 1057            {
 01058                return PlayAccess.None;
 1059            }
 1060
 1061            // if (!user.IsParentalScheduleAllowed())
 1062            // {
 1063            //    return PlayAccess.None;
 1064            // }
 1065
 61066            return PlayAccess.Full;
 1067        }
 1068
 1069        public virtual IReadOnlyList<MediaStream> GetMediaStreams()
 1070        {
 01071            return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
 01072            {
 01073                ItemId = Id
 01074            });
 1075        }
 1076
 1077        protected virtual bool IsActiveRecording()
 1078        {
 01079            return false;
 1080        }
 1081
 1082        public virtual IReadOnlyList<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
 1083        {
 01084            if (SourceType == SourceType.Channel)
 1085            {
 01086                var sources = ChannelManager.GetStaticMediaSources(this, CancellationToken.None)
 01087                           .ToList();
 1088
 01089                if (sources.Count > 0)
 1090                {
 01091                    return sources;
 1092                }
 1093            }
 1094
 01095            var list = GetAllItemsForMediaSources();
 01096            var result = list.Select(i => GetVersionInfo(enablePathSubstitution, i.Item, i.MediaSourceType)).ToList();
 1097
 01098            if (IsActiveRecording())
 1099            {
 01100                foreach (var mediaSource in result)
 1101                {
 01102                    mediaSource.Type = MediaSourceType.Placeholder;
 1103                }
 1104            }
 1105
 01106            return result.OrderBy(i =>
 01107            {
 01108                if (i.VideoType == VideoType.VideoFile)
 01109                {
 01110                    return 0;
 01111                }
 01112
 01113                return 1;
 01114            }).ThenBy(i => i.Video3DFormat.HasValue ? 1 : 0)
 01115            .ThenByDescending(i => i, new MediaSourceWidthComparator())
 01116            .ToArray();
 1117        }
 1118
 1119        protected virtual IEnumerable<(BaseItem Item, MediaSourceType MediaSourceType)> GetAllItemsForMediaSources()
 1120        {
 01121            return Enumerable.Empty<(BaseItem, MediaSourceType)>();
 1122        }
 1123
 1124        private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type)
 1125        {
 01126            ArgumentNullException.ThrowIfNull(item);
 1127
 01128            var protocol = item.PathProtocol;
 1129
 01130            var info = new MediaSourceInfo
 01131            {
 01132                Id = item.Id.ToString("N", CultureInfo.InvariantCulture),
 01133                Protocol = protocol ?? MediaProtocol.File,
 01134                MediaStreams = MediaSourceManager.GetMediaStreams(item.Id),
 01135                MediaAttachments = MediaSourceManager.GetMediaAttachments(item.Id),
 01136                Name = GetMediaSourceName(item),
 01137                Path = enablePathSubstitution ? GetMappedPath(item, item.Path, protocol) : item.Path,
 01138                RunTimeTicks = item.RunTimeTicks,
 01139                Container = item.Container,
 01140                Size = item.Size,
 01141                Type = type,
 01142                HasSegments = MediaSegmentManager.IsTypeSupported(item)
 01143                    && (protocol is null or MediaProtocol.File)
 01144                    && MediaSegmentManager.HasSegments(item.Id)
 01145            };
 1146
 01147            if (string.IsNullOrEmpty(info.Path))
 1148            {
 01149                info.Type = MediaSourceType.Placeholder;
 1150            }
 1151
 01152            if (info.Protocol == MediaProtocol.File)
 1153            {
 01154                info.ETag = item.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N", Cultur
 1155            }
 1156
 01157            var video = item as Video;
 01158            if (video is not null)
 1159            {
 01160                info.IsoType = video.IsoType;
 01161                info.VideoType = video.VideoType;
 01162                info.Video3DFormat = video.Video3DFormat;
 01163                info.Timestamp = video.Timestamp;
 1164
 01165                if (video.IsShortcut)
 1166                {
 01167                    info.IsRemote = true;
 01168                    info.Path = video.ShortcutPath;
 01169                    info.Protocol = MediaSourceManager.GetPathProtocol(info.Path);
 1170                }
 1171
 01172                if (string.IsNullOrEmpty(info.Container))
 1173                {
 01174                    if (video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Iso)
 1175                    {
 01176                        if (protocol.HasValue && protocol.Value == MediaProtocol.File)
 1177                        {
 01178                            info.Container = System.IO.Path.GetExtension(item.Path).TrimStart('.');
 1179                        }
 1180                    }
 1181                }
 1182            }
 1183
 01184            if (string.IsNullOrEmpty(info.Container))
 1185            {
 01186                if (protocol.HasValue && protocol.Value == MediaProtocol.File)
 1187                {
 01188                    info.Container = System.IO.Path.GetExtension(item.Path).TrimStart('.');
 1189                }
 1190            }
 1191
 01192            if (info.SupportsDirectStream && !string.IsNullOrEmpty(info.Path))
 1193            {
 01194                info.SupportsDirectStream = MediaSourceManager.SupportsDirectStream(info.Path, info.Protocol);
 1195            }
 1196
 01197            if (video is not null && video.VideoType != VideoType.VideoFile)
 1198            {
 01199                info.SupportsDirectStream = false;
 1200            }
 1201
 01202            info.Bitrate = item.TotalBitrate;
 01203            info.InferTotalBitrate();
 1204
 01205            return info;
 1206        }
 1207
 1208        internal string GetMediaSourceName(BaseItem item)
 1209        {
 41210            var terms = new List<string>();
 1211
 41212            var path = item.Path;
 41213            if (item.IsFileProtocol && !string.IsNullOrEmpty(path))
 1214            {
 41215                var displayName = System.IO.Path.GetFileNameWithoutExtension(path);
 41216                if (HasLocalAlternateVersions)
 1217                {
 41218                    var containingFolderName = System.IO.Path.GetFileName(ContainingFolderPath);
 41219                    if (displayName.Length > containingFolderName.Length && displayName.StartsWith(containingFolderName,
 1220                    {
 21221                        var name = displayName.AsSpan(containingFolderName.Length).TrimStart([' ', '-']);
 21222                        if (!name.IsWhiteSpace())
 1223                        {
 21224                            terms.Add(name.ToString());
 1225                        }
 1226                    }
 1227                }
 1228
 41229                if (terms.Count == 0)
 1230                {
 21231                    terms.Add(displayName);
 1232                }
 1233            }
 1234
 41235            if (terms.Count == 0)
 1236            {
 01237                terms.Add(item.Name);
 1238            }
 1239
 41240            if (item is Video video)
 1241            {
 41242                if (video.Video3DFormat.HasValue)
 1243                {
 01244                    terms.Add("3D");
 1245                }
 1246
 41247                if (video.VideoType == VideoType.BluRay)
 1248                {
 01249                    terms.Add("Bluray");
 1250                }
 41251                else if (video.VideoType == VideoType.Dvd)
 1252                {
 01253                    terms.Add("DVD");
 1254                }
 41255                else if (video.VideoType == VideoType.Iso)
 1256                {
 01257                    if (video.IsoType.HasValue)
 1258                    {
 01259                        if (video.IsoType.Value == IsoType.BluRay)
 1260                        {
 01261                            terms.Add("Bluray");
 1262                        }
 01263                        else if (video.IsoType.Value == IsoType.Dvd)
 1264                        {
 01265                            terms.Add("DVD");
 1266                        }
 1267                    }
 1268                    else
 1269                    {
 01270                        terms.Add("ISO");
 1271                    }
 1272                }
 1273            }
 1274
 41275            return string.Join('/', terms);
 1276        }
 1277
 1278        public Task RefreshMetadata(CancellationToken cancellationToken)
 1279        {
 481280            return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(FileSystem)), cancellationToken);
 1281        }
 1282
 1283        /// <summary>
 1284        /// The base implementation to refresh metadata.
 1285        /// </summary>
 1286        /// <param name="options">The options.</param>
 1287        /// <param name="cancellationToken">The cancellation token.</param>
 1288        /// <returns>true if a provider reports we changed.</returns>
 1289        public async Task<ItemUpdateType> RefreshMetadata(MetadataRefreshOptions options, CancellationToken cancellation
 1290        {
 1291            var requiresSave = false;
 1292
 1293            if (SupportsOwnedItems)
 1294            {
 1295                try
 1296                {
 1297                    if (IsFileProtocol)
 1298                    {
 1299                        requiresSave = await RefreshedOwnedItems(options, GetFileSystemChildren(options.DirectoryService
 1300                    }
 1301
 1302                    await LibraryManager.UpdateImagesAsync(this).ConfigureAwait(false); // ensure all image properties i
 1303                }
 1304                catch (Exception ex)
 1305                {
 1306                    Logger.LogError(ex, "Error refreshing owned items for {Path}", Path ?? Name);
 1307                }
 1308            }
 1309
 1310            var refreshOptions = requiresSave
 1311                ? new MetadataRefreshOptions(options)
 1312                {
 1313                    ForceSave = true
 1314                }
 1315                : options;
 1316
 1317            return await ProviderManager.RefreshSingleItem(this, refreshOptions, cancellationToken).ConfigureAwait(false
 1318        }
 1319
 1320        protected bool IsVisibleStandaloneInternal(User user, bool checkFolders)
 1321        {
 01322            if (!IsVisible(user))
 1323            {
 01324                return false;
 1325            }
 1326
 01327            if (GetParents().Any(i => !i.IsVisible(user, true)))
 1328            {
 01329                return false;
 1330            }
 1331
 01332            if (checkFolders)
 1333            {
 01334                var topParent = GetParents().LastOrDefault() ?? this;
 1335
 01336                if (string.IsNullOrEmpty(topParent.Path))
 1337                {
 01338                    return true;
 1339                }
 1340
 01341                var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList();
 1342
 01343                if (itemCollectionFolders.Count > 0)
 1344                {
 01345                    var userCollectionFolders = LibraryManager.GetUserRootFolder().GetChildren(user, true).Select(i => i
 01346                    if (!itemCollectionFolders.Any(userCollectionFolders.Contains))
 1347                    {
 01348                        return false;
 1349                    }
 1350                }
 1351            }
 1352
 01353            return true;
 1354        }
 1355
 1356        public void SetParent(Folder parent)
 1357        {
 101358            ParentId = parent is null ? Guid.Empty : parent.Id;
 101359        }
 1360
 1361        /// <summary>
 1362        /// Refreshes owned items such as trailers, theme videos, special features, etc.
 1363        /// Returns true or false indicating if changes were found.
 1364        /// </summary>
 1365        /// <param name="options">The metadata refresh options.</param>
 1366        /// <param name="fileSystemChildren">The list of filesystem children.</param>
 1367        /// <param name="cancellationToken">The cancellation token.</param>
 1368        /// <returns><c>true</c> if any items have changed, else <c>false</c>.</returns>
 1369        protected virtual async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, IReadOnlyList<FileSystemM
 1370        {
 1371            if (!IsFileProtocol || !SupportsOwnedItems || IsInMixedFolder || this is ICollectionFolder or UserRootFolder
 1372            {
 1373                return false;
 1374            }
 1375
 1376            return await RefreshExtras(this, options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
 1377        }
 1378
 1379        protected virtual FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService)
 1380        {
 421381            return directoryService.GetFileSystemEntries(ContainingFolderPath);
 1382        }
 1383
 1384        private async Task<bool> RefreshExtras(BaseItem item, MetadataRefreshOptions options, IReadOnlyList<FileSystemMe
 1385        {
 1386            var extras = LibraryManager.FindExtras(item, fileSystemChildren, options.DirectoryService).ToArray();
 1387            var newExtraIds = Array.ConvertAll(extras, x => x.Id);
 1388            var extrasChanged = !item.ExtraIds.SequenceEqual(newExtraIds);
 1389
 1390            if (!extrasChanged && !options.ReplaceAllMetadata && options.MetadataRefreshMode != MetadataRefreshMode.Full
 1391            {
 1392                return false;
 1393            }
 1394
 1395            var ownerId = item.Id;
 1396
 1397            var tasks = extras.Select(i =>
 1398            {
 1399                var subOptions = new MetadataRefreshOptions(options);
 1400                if (!i.OwnerId.Equals(ownerId) || !i.ParentId.IsEmpty())
 1401                {
 1402                    i.OwnerId = ownerId;
 1403                    i.ParentId = Guid.Empty;
 1404                    subOptions.ForceSave = true;
 1405                }
 1406
 1407                return RefreshMetadataForOwnedItem(i, true, subOptions, cancellationToken);
 1408            });
 1409
 1410            // Cleanup removed extras
 1411            var removedExtraIds = item.ExtraIds.Where(e => !newExtraIds.Contains(e)).ToArray();
 1412            if (removedExtraIds.Length > 0)
 1413            {
 1414                var removedExtras = LibraryManager.GetItemList(new InternalItemsQuery()
 1415                {
 1416                    ItemIds = removedExtraIds
 1417                });
 1418                foreach (var removedExtra in removedExtras)
 1419                {
 1420                    LibraryManager.DeleteItem(removedExtra, new DeleteOptions()
 1421                    {
 1422                        DeleteFileLocation = false
 1423                    });
 1424                }
 1425            }
 1426
 1427            await Task.WhenAll(tasks).ConfigureAwait(false);
 1428
 1429            item.ExtraIds = newExtraIds;
 1430
 1431            return true;
 1432        }
 1433
 1434        public string GetPresentationUniqueKey()
 1435        {
 01436            return PresentationUniqueKey ?? CreatePresentationUniqueKey();
 1437        }
 1438
 1439        public virtual bool RequiresRefresh()
 1440        {
 561441            if (string.IsNullOrEmpty(Path) || DateModified == DateTime.MinValue)
 1442            {
 01443                return false;
 1444            }
 1445
 561446            var info = FileSystem.GetFileSystemInfo(Path);
 1447
 561448            return info.Exists && this.HasChanged(info.LastWriteTimeUtc);
 1449        }
 1450
 1451        public virtual List<string> GetUserDataKeys()
 1452        {
 1231453            var list = new List<string>();
 1454
 1231455            if (SourceType == SourceType.Channel)
 1456            {
 01457                if (!string.IsNullOrEmpty(ExternalId))
 1458                {
 01459                    list.Add(ExternalId);
 1460                }
 1461            }
 1462
 1231463            list.Add(Id.ToString());
 1231464            return list;
 1465        }
 1466
 1467        internal virtual ItemUpdateType UpdateFromResolvedItem(BaseItem newItem)
 1468        {
 61469            var updateType = ItemUpdateType.None;
 1470
 61471            if (IsInMixedFolder != newItem.IsInMixedFolder)
 1472            {
 01473                IsInMixedFolder = newItem.IsInMixedFolder;
 01474                updateType |= ItemUpdateType.MetadataImport;
 1475            }
 1476
 61477            return updateType;
 1478        }
 1479
 1480        public void AfterMetadataRefresh()
 1481        {
 551482            _sortName = null;
 551483        }
 1484
 1485        /// <summary>
 1486        /// Gets the preferred metadata language.
 1487        /// </summary>
 1488        /// <returns>System.String.</returns>
 1489        public string GetPreferredMetadataLanguage()
 1490        {
 551491            string lang = PreferredMetadataLanguage;
 1492
 551493            if (string.IsNullOrEmpty(lang))
 1494            {
 551495                lang = GetParents()
 551496                    .Select(i => i.PreferredMetadataLanguage)
 551497                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1498            }
 1499
 551500            if (string.IsNullOrEmpty(lang))
 1501            {
 551502                lang = LibraryManager.GetCollectionFolders(this)
 551503                    .Select(i => i.PreferredMetadataLanguage)
 551504                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1505            }
 1506
 551507            if (string.IsNullOrEmpty(lang))
 1508            {
 551509                lang = LibraryManager.GetLibraryOptions(this).PreferredMetadataLanguage;
 1510            }
 1511
 551512            if (string.IsNullOrEmpty(lang))
 1513            {
 551514                lang = ConfigurationManager.Configuration.PreferredMetadataLanguage;
 1515            }
 1516
 551517            return lang;
 1518        }
 1519
 1520        /// <summary>
 1521        /// Gets the preferred metadata language.
 1522        /// </summary>
 1523        /// <returns>System.String.</returns>
 1524        public string GetPreferredMetadataCountryCode()
 1525        {
 551526            string lang = PreferredMetadataCountryCode;
 1527
 551528            if (string.IsNullOrEmpty(lang))
 1529            {
 551530                lang = GetParents()
 551531                    .Select(i => i.PreferredMetadataCountryCode)
 551532                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1533            }
 1534
 551535            if (string.IsNullOrEmpty(lang))
 1536            {
 551537                lang = LibraryManager.GetCollectionFolders(this)
 551538                    .Select(i => i.PreferredMetadataCountryCode)
 551539                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1540            }
 1541
 551542            if (string.IsNullOrEmpty(lang))
 1543            {
 551544                lang = LibraryManager.GetLibraryOptions(this).MetadataCountryCode;
 1545            }
 1546
 551547            if (string.IsNullOrEmpty(lang))
 1548            {
 551549                lang = ConfigurationManager.Configuration.MetadataCountryCode;
 1550            }
 1551
 551552            return lang;
 1553        }
 1554
 1555        public virtual bool IsSaveLocalMetadataEnabled()
 1556        {
 861557            if (SourceType == SourceType.Channel)
 1558            {
 01559                return false;
 1560            }
 1561
 861562            var libraryOptions = LibraryManager.GetLibraryOptions(this);
 1563
 861564            return libraryOptions.SaveLocalMetadata;
 1565        }
 1566
 1567        /// <summary>
 1568        /// Determines if a given user has access to this item.
 1569        /// </summary>
 1570        /// <param name="user">The user.</param>
 1571        /// <param name="skipAllowedTagsCheck">Don't check for allowed tags.</param>
 1572        /// <returns><c>true</c> if [is parental allowed] [the specified user]; otherwise, <c>false</c>.</returns>
 1573        /// <exception cref="ArgumentNullException">If user is null.</exception>
 1574        public bool IsParentalAllowed(User user, bool skipAllowedTagsCheck)
 1575        {
 131576            ArgumentNullException.ThrowIfNull(user);
 1577
 131578            if (!IsVisibleViaTags(user, skipAllowedTagsCheck))
 1579            {
 01580                return false;
 1581            }
 1582
 131583            var maxAllowedRating = user.MaxParentalRatingScore;
 131584            var maxAllowedSubRating = user.MaxParentalRatingSubScore;
 131585            var rating = CustomRatingForComparison;
 1586
 131587            if (string.IsNullOrEmpty(rating))
 1588            {
 131589                rating = OfficialRatingForComparison;
 1590            }
 1591
 131592            if (string.IsNullOrEmpty(rating))
 1593            {
 131594                Logger.LogDebug("{0} has no parental rating set.", Name);
 131595                return !GetBlockUnratedValue(user);
 1596            }
 1597
 01598            var ratingScore = LocalizationManager.GetRatingScore(rating);
 1599
 1600            // Could not determine rating level
 01601            if (ratingScore is null)
 1602            {
 01603                var isAllowed = !GetBlockUnratedValue(user);
 1604
 01605                if (!isAllowed)
 1606                {
 01607                    Logger.LogDebug("{0} has an unrecognized parental rating of {1}.", Name, rating);
 1608                }
 1609
 01610                return isAllowed;
 1611            }
 1612
 01613            if (maxAllowedSubRating is not null)
 1614            {
 01615                return (ratingScore.SubScore ?? 0) <= maxAllowedSubRating && ratingScore.Score <= maxAllowedRating.Value
 1616            }
 1617
 01618            return !maxAllowedRating.HasValue || ratingScore.Score <= maxAllowedRating.Value;
 1619        }
 1620
 1621        public ParentalRatingScore GetParentalRatingScore()
 1622        {
 1101623            var rating = CustomRatingForComparison;
 1624
 1101625            if (string.IsNullOrEmpty(rating))
 1626            {
 1101627                rating = OfficialRatingForComparison;
 1628            }
 1629
 1101630            if (string.IsNullOrEmpty(rating))
 1631            {
 1101632                return null;
 1633            }
 1634
 01635            return LocalizationManager.GetRatingScore(rating);
 1636        }
 1637
 1638        public List<string> GetInheritedTags()
 1639        {
 1271640            var list = new List<string>();
 1271641            list.AddRange(Tags);
 1642
 3341643            foreach (var parent in GetParents())
 1644            {
 401645                list.AddRange(parent.Tags);
 1646            }
 1647
 2541648            foreach (var folder in LibraryManager.GetCollectionFolders(this))
 1649            {
 01650                list.AddRange(folder.Tags);
 1651            }
 1652
 1271653            return list.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
 1654        }
 1655
 1656        private bool IsVisibleViaTags(User user, bool skipAllowedTagsCheck)
 1657        {
 131658            var allTags = GetInheritedTags();
 131659            if (user.GetPreference(PreferenceKind.BlockedTags).Any(i => allTags.Contains(i, StringComparison.OrdinalIgno
 1660            {
 01661                return false;
 1662            }
 1663
 131664            var parent = GetParents().FirstOrDefault() ?? this;
 131665            if (parent is UserRootFolder or AggregateFolder or UserView)
 1666            {
 131667                return true;
 1668            }
 1669
 01670            var allowedTagsPreference = user.GetPreference(PreferenceKind.AllowedTags);
 01671            if (!skipAllowedTagsCheck && allowedTagsPreference.Length != 0 && !allowedTagsPreference.Any(i => allTags.Co
 1672            {
 01673                return false;
 1674            }
 1675
 01676            return true;
 1677        }
 1678
 1679        public virtual UnratedItem GetBlockUnratedType()
 1680        {
 1141681            if (SourceType == SourceType.Channel)
 1682            {
 01683                return UnratedItem.ChannelContent;
 1684            }
 1685
 1141686            return UnratedItem.Other;
 1687        }
 1688
 1689        /// <summary>
 1690        /// Gets a bool indicating if access to the unrated item is blocked or not.
 1691        /// </summary>
 1692        /// <param name="user">The configuration.</param>
 1693        /// <returns><c>true</c> if blocked, <c>false</c> otherwise.</returns>
 1694        protected virtual bool GetBlockUnratedValue(User user)
 1695        {
 1696            // Don't block plain folders that are unrated. Let the media underneath get blocked
 1697            // Special folders like series and albums will override this method.
 131698            if (IsFolder || this is IItemByName)
 1699            {
 131700                return false;
 1701            }
 1702
 01703            return user.GetPreferenceValues<UnratedItem>(PreferenceKind.BlockUnratedItems).Contains(GetBlockUnratedType(
 1704        }
 1705
 1706        /// <summary>
 1707        /// Determines if this folder should be visible to a given user.
 1708        /// Default is just parental allowed. Can be overridden for more functionality.
 1709        /// </summary>
 1710        /// <param name="user">The user.</param>
 1711        /// <param name="skipAllowedTagsCheck">Don't check for allowed tags.</param>
 1712        /// <returns><c>true</c> if the specified user is visible; otherwise, <c>false</c>.</returns>
 1713        /// <exception cref="ArgumentNullException"><paramref name="user" /> is <c>null</c>.</exception>
 1714        public virtual bool IsVisible(User user, bool skipAllowedTagsCheck = false)
 1715        {
 131716            ArgumentNullException.ThrowIfNull(user);
 1717
 131718            return IsParentalAllowed(user, skipAllowedTagsCheck);
 1719        }
 1720
 1721        public virtual bool IsVisibleStandalone(User user)
 1722        {
 01723            if (SourceType == SourceType.Channel)
 1724            {
 01725                return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
 1726            }
 1727
 01728            return IsVisibleStandaloneInternal(user, true);
 1729        }
 1730
 1731        public virtual string GetClientTypeName()
 1732        {
 1021733            if (IsFolder && SourceType == SourceType.Channel && this is not Channel && this is not Season && this is not
 1734            {
 01735                return "ChannelFolderItem";
 1736            }
 1737
 1021738            return GetType().Name;
 1739        }
 1740
 1741        public BaseItemKind GetBaseItemKind()
 1742        {
 2181743            return _baseItemKind ??= Enum.Parse<BaseItemKind>(GetClientTypeName());
 1744        }
 1745
 1746        /// <summary>
 1747        /// Gets the linked child.
 1748        /// </summary>
 1749        /// <param name="info">The info.</param>
 1750        /// <returns>BaseItem.</returns>
 1751        protected BaseItem GetLinkedChild(LinkedChild info)
 1752        {
 1753            // First get using the cached Id
 01754            if (info.ItemId.HasValue)
 1755            {
 01756                if (info.ItemId.Value.IsEmpty())
 1757                {
 01758                    return null;
 1759                }
 1760
 01761                var itemById = LibraryManager.GetItemById(info.ItemId.Value);
 1762
 01763                if (itemById is not null)
 1764                {
 01765                    return itemById;
 1766                }
 1767            }
 1768
 01769            var item = FindLinkedChild(info);
 1770
 1771            // If still null, log
 01772            if (item is null)
 1773            {
 1774                // Don't keep searching over and over
 01775                info.ItemId = Guid.Empty;
 1776            }
 1777            else
 1778            {
 1779                // Cache the id for next time
 01780                info.ItemId = item.Id;
 1781            }
 1782
 01783            return item;
 1784        }
 1785
 1786        private BaseItem FindLinkedChild(LinkedChild info)
 1787        {
 01788            var path = info.Path;
 1789
 01790            if (!string.IsNullOrEmpty(path))
 1791            {
 01792                path = FileSystem.MakeAbsolutePath(ContainingFolderPath, path);
 1793
 01794                var itemByPath = LibraryManager.FindByPath(path, null);
 1795
 01796                if (itemByPath is null)
 1797                {
 01798                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1799                }
 1800
 01801                return itemByPath;
 1802            }
 1803
 01804            if (!string.IsNullOrEmpty(info.LibraryItemId))
 1805            {
 01806                var item = LibraryManager.GetItemById(info.LibraryItemId);
 1807
 01808                if (item is null)
 1809                {
 01810                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1811                }
 1812
 01813                return item;
 1814            }
 1815
 01816            return null;
 1817        }
 1818
 1819        /// <summary>
 1820        /// Adds a studio to the item.
 1821        /// </summary>
 1822        /// <param name="name">The name.</param>
 1823        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1824        public void AddStudio(string name)
 1825        {
 41826            ArgumentException.ThrowIfNullOrEmpty(name);
 41827            var current = Studios;
 1828
 41829            if (!current.Contains(name, StringComparison.OrdinalIgnoreCase))
 1830            {
 41831                int curLen = current.Length;
 41832                if (curLen == 0)
 1833                {
 41834                    Studios = [name];
 1835                }
 1836                else
 1837                {
 01838                    Studios = [.. current, name];
 1839                }
 1840            }
 01841        }
 1842
 1843        public void SetStudios(IEnumerable<string> names)
 1844        {
 01845            Studios = names.Trimmed().Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
 01846        }
 1847
 1848        /// <summary>
 1849        /// Adds a genre to the item.
 1850        /// </summary>
 1851        /// <param name="name">The name.</param>
 1852        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1853        public void AddGenre(string name)
 1854        {
 131855            ArgumentException.ThrowIfNullOrEmpty(name);
 1856
 131857            var genres = Genres;
 131858            if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))
 1859            {
 131860                Genres = [.. genres, name];
 1861            }
 131862        }
 1863
 1864        /// <summary>
 1865        /// Marks the played.
 1866        /// </summary>
 1867        /// <param name="user">The user.</param>
 1868        /// <param name="datePlayed">The date played.</param>
 1869        /// <param name="resetPosition">if set to <c>true</c> [reset position].</param>
 1870        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1871        public virtual void MarkPlayed(
 1872            User user,
 1873            DateTime? datePlayed,
 1874            bool resetPosition)
 1875        {
 01876            ArgumentNullException.ThrowIfNull(user);
 1877
 01878            var data = UserDataManager.GetUserData(user, this) ?? new UserItemData()
 01879            {
 01880                Key = GetUserDataKeys().First(),
 01881            };
 1882
 01883            if (datePlayed.HasValue)
 1884            {
 1885                // Increment
 01886                data.PlayCount++;
 1887            }
 1888
 1889            // Ensure it's at least one
 01890            data.PlayCount = Math.Max(data.PlayCount, 1);
 1891
 01892            if (resetPosition)
 1893            {
 01894                data.PlaybackPositionTicks = 0;
 1895            }
 1896
 01897            data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
 01898            data.Played = true;
 1899
 01900            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01901        }
 1902
 1903        /// <summary>
 1904        /// Marks the unplayed.
 1905        /// </summary>
 1906        /// <param name="user">The user.</param>
 1907        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1908        public virtual void MarkUnplayed(User user)
 1909        {
 01910            ArgumentNullException.ThrowIfNull(user);
 1911
 01912            var data = UserDataManager.GetUserData(user, this);
 1913
 1914            // I think it is okay to do this here.
 1915            // if this is only called when a user is manually forcing something to un-played
 1916            // then it probably is what we want to do...
 01917            data.PlayCount = 0;
 01918            data.PlaybackPositionTicks = 0;
 01919            data.LastPlayedDate = null;
 01920            data.Played = false;
 1921
 01922            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01923        }
 1924
 1925        /// <summary>
 1926        /// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed.
 1927        /// </summary>
 1928        public virtual void ChangedExternally()
 1929        {
 01930            ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem)), RefreshPriori
 01931        }
 1932
 1933        /// <summary>
 1934        /// Gets an image.
 1935        /// </summary>
 1936        /// <param name="type">The type.</param>
 1937        /// <param name="imageIndex">Index of the image.</param>
 1938        /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
 1939        /// <exception cref="ArgumentException">Backdrops should be accessed using Item.Backdrops.</exception>
 1940        public bool HasImage(ImageType type, int imageIndex)
 1941        {
 1431942            return GetImageInfo(type, imageIndex) is not null;
 1943        }
 1944
 1945        public void SetImage(ItemImageInfo image, int index)
 1946        {
 131947            if (image.Type == ImageType.Chapter)
 1948            {
 01949                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1950            }
 1951
 131952            var existingImage = GetImageInfo(image.Type, index);
 1953
 131954            if (existingImage is null)
 1955            {
 111956                AddImage(image);
 1957            }
 1958            else
 1959            {
 21960                existingImage.Path = image.Path;
 21961                existingImage.DateModified = image.DateModified;
 21962                existingImage.Width = image.Width;
 21963                existingImage.Height = image.Height;
 21964                existingImage.BlurHash = image.BlurHash;
 1965            }
 21966        }
 1967
 1968        public void SetImagePath(ImageType type, int index, FileSystemMetadata file)
 1969        {
 461970            if (type == ImageType.Chapter)
 1971            {
 01972                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1973            }
 1974
 461975            var image = GetImageInfo(type, index);
 1976
 461977            if (image is null)
 1978            {
 451979                AddImage(GetImageInfo(file, type));
 1980            }
 1981            else
 1982            {
 11983                var imageInfo = GetImageInfo(file, type);
 1984
 11985                image.Path = file.FullName;
 11986                image.DateModified = imageInfo.DateModified;
 1987
 1988                // reset these values
 11989                image.Width = 0;
 11990                image.Height = 0;
 1991            }
 11992        }
 1993
 1994        /// <summary>
 1995        /// Deletes the image.
 1996        /// </summary>
 1997        /// <param name="type">The type.</param>
 1998        /// <param name="index">The index.</param>
 1999        /// <returns>A task.</returns>
 2000        public async Task DeleteImageAsync(ImageType type, int index)
 2001        {
 2002            var info = GetImageInfo(type, index);
 2003
 2004            if (info is null)
 2005            {
 2006                // Nothing to do
 2007                return;
 2008            }
 2009
 2010            // Remove from file system
 2011            var path = info.Path;
 2012            if (info.IsLocalFile && !string.IsNullOrWhiteSpace(path))
 2013            {
 2014                FileSystem.DeleteFile(path);
 2015            }
 2016
 2017            // Remove from item
 2018            RemoveImage(info);
 2019
 2020            await UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None).ConfigureAwait(false);
 2021        }
 2022
 2023        public void RemoveImage(ItemImageInfo image)
 2024        {
 02025            RemoveImages([image]);
 02026        }
 2027
 2028        public void RemoveImages(IEnumerable<ItemImageInfo> deletedImages)
 2029        {
 92030            ImageInfos = ImageInfos.Except(deletedImages).ToArray();
 92031        }
 2032
 2033        public void AddImage(ItemImageInfo image)
 2034        {
 562035            ImageInfos = [.. ImageInfos, image];
 562036        }
 2037
 2038        public virtual async Task UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationTok
 2039         => await LibraryManager.UpdateItemAsync(this, GetParent(), updateReason, cancellationToken).ConfigureAwait(fals
 2040
 2041        /// <summary>
 2042        /// Validates that images within the item are still on the filesystem.
 2043        /// </summary>
 2044        /// <returns><c>true</c> if the images validate, <c>false</c> if not.</returns>
 2045        public bool ValidateImages()
 2046        {
 692047            List<ItemImageInfo> deletedImages = null;
 1682048            foreach (var imageInfo in ImageInfos)
 2049            {
 152050                if (!imageInfo.IsLocalFile)
 2051                {
 2052                    continue;
 2053                }
 2054
 152055                if (File.Exists(imageInfo.Path))
 2056                {
 2057                    continue;
 2058                }
 2059
 32060                (deletedImages ??= []).Add(imageInfo);
 2061            }
 2062
 692063            var anyImagesRemoved = deletedImages?.Count > 0;
 692064            if (anyImagesRemoved)
 2065            {
 22066                RemoveImages(deletedImages);
 2067            }
 2068
 692069            return anyImagesRemoved;
 2070        }
 2071
 2072        /// <summary>
 2073        /// Gets the image path.
 2074        /// </summary>
 2075        /// <param name="imageType">Type of the image.</param>
 2076        /// <param name="imageIndex">Index of the image.</param>
 2077        /// <returns>System.String.</returns>
 2078        /// <exception cref="ArgumentNullException">Item is null.</exception>
 2079        public string GetImagePath(ImageType imageType, int imageIndex)
 22080            => GetImageInfo(imageType, imageIndex)?.Path;
 2081
 2082        /// <summary>
 2083        /// Gets the image information.
 2084        /// </summary>
 2085        /// <param name="imageType">Type of the image.</param>
 2086        /// <param name="imageIndex">Index of the image.</param>
 2087        /// <returns>ItemImageInfo.</returns>
 2088        public ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex)
 2089        {
 3162090            if (imageType == ImageType.Chapter)
 2091            {
 02092                var chapter = ChapterManager.GetChapter(Id, imageIndex);
 2093
 02094                if (chapter is null)
 2095                {
 02096                    return null;
 2097                }
 2098
 02099                var path = chapter.ImagePath;
 2100
 02101                if (string.IsNullOrEmpty(path))
 2102                {
 02103                    return null;
 2104                }
 2105
 02106                return new ItemImageInfo
 02107                {
 02108                    Path = path,
 02109                    DateModified = chapter.ImageDateModified,
 02110                    Type = imageType
 02111                };
 2112            }
 2113
 2114            // Music albums usually don't have dedicated backdrops, so return one from the artist instead
 3162115            if (GetType() == typeof(MusicAlbum) && imageType == ImageType.Backdrop)
 2116            {
 02117                var artist = FindParent<MusicArtist>();
 2118
 02119                if (artist is not null)
 2120                {
 02121                    return artist.GetImages(imageType).ElementAtOrDefault(imageIndex);
 2122                }
 2123            }
 2124
 3162125            return GetImages(imageType)
 3162126                .ElementAtOrDefault(imageIndex);
 2127        }
 2128
 2129        /// <summary>
 2130        /// Computes image index for given image or raises if no matching image found.
 2131        /// </summary>
 2132        /// <param name="image">Image to compute index for.</param>
 2133        /// <exception cref="ArgumentException">Image index cannot be computed as no matching image found.
 2134        /// </exception>
 2135        /// <returns>Image index.</returns>
 2136        public int GetImageIndex(ItemImageInfo image)
 2137        {
 02138            ArgumentNullException.ThrowIfNull(image);
 2139
 02140            if (image.Type == ImageType.Chapter)
 2141            {
 02142                var chapters = ChapterManager.GetChapters(Id);
 02143                for (var i = 0; i < chapters.Count; i++)
 2144                {
 02145                    if (chapters[i].ImagePath == image.Path)
 2146                    {
 02147                        return i;
 2148                    }
 2149                }
 2150
 02151                throw new ArgumentException("No chapter index found for image path", image.Path);
 2152            }
 2153
 02154            var images = GetImages(image.Type).ToArray();
 02155            for (var i = 0; i < images.Length; i++)
 2156            {
 02157                if (images[i].Path == image.Path)
 2158                {
 02159                    return i;
 2160                }
 2161            }
 2162
 02163            throw new ArgumentException("No image index found for image path", image.Path);
 2164        }
 2165
 2166        public IEnumerable<ItemImageInfo> GetImages(ImageType imageType)
 2167        {
 2168            if (imageType == ImageType.Chapter)
 2169            {
 2170                throw new ArgumentException("No image info for chapter images");
 2171            }
 2172
 2173            // Yield return is more performant than LINQ Where on an Array
 2174            for (var i = 0; i < ImageInfos.Length; i++)
 2175            {
 2176                var imageInfo = ImageInfos[i];
 2177                if (imageInfo.Type == imageType)
 2178                {
 2179                    yield return imageInfo;
 2180                }
 2181            }
 2182        }
 2183
 2184        /// <summary>
 2185        /// Adds the images, updating metadata if they already are part of this item.
 2186        /// </summary>
 2187        /// <param name="imageType">Type of the image.</param>
 2188        /// <param name="images">The images.</param>
 2189        /// <returns><c>true</c> if images were added or updated, <c>false</c> otherwise.</returns>
 2190        /// <exception cref="ArgumentException">Cannot call AddImages with chapter images.</exception>
 2191        public bool AddImages(ImageType imageType, List<FileSystemMetadata> images)
 2192        {
 692193            if (imageType == ImageType.Chapter)
 2194            {
 02195                throw new ArgumentException("Cannot call AddImages with chapter images");
 2196            }
 2197
 692198            var existingImages = GetImages(imageType)
 692199                .ToList();
 2200
 692201            var newImageList = new List<FileSystemMetadata>();
 692202            var imageUpdated = false;
 2203
 1542204            foreach (var newImage in images)
 2205            {
 82206                if (newImage is null)
 2207                {
 02208                    throw new ArgumentException("null image found in list");
 2209                }
 2210
 82211                var existing = existingImages
 82212                    .Find(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase));
 2213
 82214                if (existing is null)
 2215                {
 42216                    newImageList.Add(newImage);
 2217                }
 2218                else
 2219                {
 42220                    if (existing.IsLocalFile)
 2221                    {
 42222                        var newDateModified = FileSystem.GetLastWriteTimeUtc(newImage);
 2223
 2224                        // If date changed then we need to reset saved image dimensions
 42225                        if (existing.DateModified != newDateModified && (existing.Width > 0 || existing.Height > 0))
 2226                        {
 22227                            existing.Width = 0;
 22228                            existing.Height = 0;
 22229                            imageUpdated = true;
 2230                        }
 2231
 42232                        existing.DateModified = newDateModified;
 2233                    }
 2234                }
 2235            }
 2236
 692237            if (newImageList.Count > 0)
 2238            {
 22239                ImageInfos = ImageInfos.Concat(newImageList.Select(i => GetImageInfo(i, imageType))).ToArray();
 2240            }
 2241
 692242            return imageUpdated || newImageList.Count > 0;
 2243        }
 2244
 2245        private ItemImageInfo GetImageInfo(FileSystemMetadata file, ImageType type)
 2246        {
 502247            return new ItemImageInfo
 502248            {
 502249                Path = file.FullName,
 502250                Type = type,
 502251                DateModified = FileSystem.GetLastWriteTimeUtc(file)
 502252            };
 2253        }
 2254
 2255        /// <summary>
 2256        /// Gets the file system path to delete when the item is to be deleted.
 2257        /// </summary>
 2258        /// <returns>The metadata for the deleted paths.</returns>
 2259        public virtual IEnumerable<FileSystemMetadata> GetDeletePaths()
 2260        {
 02261            return new[]
 02262            {
 02263                FileSystem.GetFileSystemInfo(Path)
 02264            }.Concat(GetLocalMetadataFilesToDelete());
 2265        }
 2266
 2267        protected List<FileSystemMetadata> GetLocalMetadataFilesToDelete()
 2268        {
 02269            if (IsFolder || !IsInMixedFolder)
 2270            {
 02271                return [];
 2272            }
 2273
 02274            var filename = System.IO.Path.GetFileNameWithoutExtension(Path);
 2275
 02276            return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), _supportedExtensions, false, false)
 02277                .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison
 02278                .ToList();
 2279        }
 2280
 2281        public bool AllowsMultipleImages(ImageType type)
 2282        {
 182283            return type == ImageType.Backdrop || type == ImageType.Chapter;
 2284        }
 2285
 2286        public Task SwapImagesAsync(ImageType type, int index1, int index2)
 2287        {
 02288            if (!AllowsMultipleImages(type))
 2289            {
 02290                throw new ArgumentException("The change index operation is only applicable to backdrops and screen shots
 2291            }
 2292
 02293            var info1 = GetImageInfo(type, index1);
 02294            var info2 = GetImageInfo(type, index2);
 2295
 02296            if (info1 is null || info2 is null)
 2297            {
 2298                // Nothing to do
 02299                return Task.CompletedTask;
 2300            }
 2301
 02302            if (!info1.IsLocalFile || !info2.IsLocalFile)
 2303            {
 2304                // TODO: Not supported  yet
 02305                return Task.CompletedTask;
 2306            }
 2307
 02308            var path1 = info1.Path;
 02309            var path2 = info2.Path;
 2310
 02311            FileSystem.SwapFiles(path1, path2);
 2312
 2313            // Refresh these values
 02314            info1.DateModified = FileSystem.GetLastWriteTimeUtc(info1.Path);
 02315            info2.DateModified = FileSystem.GetLastWriteTimeUtc(info2.Path);
 2316
 02317            info1.Width = 0;
 02318            info1.Height = 0;
 02319            info2.Width = 0;
 02320            info2.Height = 0;
 2321
 02322            return UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None);
 2323        }
 2324
 2325        public virtual bool IsPlayed(User user, UserItemData userItemData)
 2326        {
 02327            userItemData ??= UserDataManager.GetUserData(user, this);
 2328
 02329            return userItemData is not null && userItemData.Played;
 2330        }
 2331
 2332        public bool IsFavoriteOrLiked(User user, UserItemData userItemData)
 2333        {
 02334            userItemData ??= UserDataManager.GetUserData(user, this);
 2335
 02336            return userItemData is not null && (userItemData.IsFavorite || (userItemData.Likes ?? false));
 2337        }
 2338
 2339        public virtual bool IsUnplayed(User user, UserItemData userItemData)
 2340        {
 02341            ArgumentNullException.ThrowIfNull(user);
 2342
 02343            userItemData ??= UserDataManager.GetUserData(user, this);
 2344
 02345            return userItemData is null || !userItemData.Played;
 2346        }
 2347
 2348        ItemLookupInfo IHasLookupInfo<ItemLookupInfo>.GetLookupInfo()
 2349        {
 552350            return GetItemLookupInfo<ItemLookupInfo>();
 2351        }
 2352
 2353        protected T GetItemLookupInfo<T>()
 2354            where T : ItemLookupInfo, new()
 2355        {
 552356            return new T
 552357            {
 552358                Path = Path,
 552359                MetadataCountryCode = GetPreferredMetadataCountryCode(),
 552360                MetadataLanguage = GetPreferredMetadataLanguage(),
 552361                Name = GetNameForMetadataLookup(),
 552362                OriginalTitle = OriginalTitle,
 552363                ProviderIds = ProviderIds,
 552364                IndexNumber = IndexNumber,
 552365                ParentIndexNumber = ParentIndexNumber,
 552366                Year = ProductionYear,
 552367                PremiereDate = PremiereDate
 552368            };
 2369        }
 2370
 2371        protected virtual string GetNameForMetadataLookup()
 2372        {
 552373            return Name;
 2374        }
 2375
 2376        /// <summary>
 2377        /// This is called before any metadata refresh and returns true if changes were made.
 2378        /// </summary>
 2379        /// <param name="replaceAllMetadata">Whether to replace all metadata.</param>
 2380        /// <returns>true if the item has change, else false.</returns>
 2381        public virtual bool BeforeMetadataRefresh(bool replaceAllMetadata)
 2382        {
 552383            _sortName = null;
 2384
 552385            var hasChanges = false;
 2386
 552387            if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path))
 2388            {
 02389                Name = System.IO.Path.GetFileNameWithoutExtension(Path);
 02390                hasChanges = true;
 2391            }
 2392
 552393            return hasChanges;
 2394        }
 2395
 2396        protected static string GetMappedPath(BaseItem item, string path, MediaProtocol? protocol)
 2397        {
 02398            if (protocol == MediaProtocol.File)
 2399            {
 02400                return LibraryManager.GetPathAfterNetworkSubstitution(path, item);
 2401            }
 2402
 02403            return path;
 2404        }
 2405
 2406        public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User 
 2407        {
 02408            if (RunTimeTicks.HasValue)
 2409            {
 02410                double pct = RunTimeTicks.Value;
 2411
 02412                if (pct > 0)
 2413                {
 02414                    pct = userData.PlaybackPositionTicks / pct;
 2415
 02416                    if (pct > 0)
 2417                    {
 02418                        dto.PlayedPercentage = 100 * pct;
 2419                    }
 2420                }
 2421            }
 02422        }
 2423
 2424        protected async Task RefreshMetadataForOwnedItem(BaseItem ownedItem, bool copyTitleMetadata, MetadataRefreshOpti
 2425        {
 2426            var newOptions = new MetadataRefreshOptions(options)
 2427            {
 2428                SearchResult = null
 2429            };
 2430
 2431            var item = this;
 2432
 2433            if (copyTitleMetadata)
 2434            {
 2435                // Take some data from the main item, for querying purposes
 2436                if (!item.Genres.SequenceEqual(ownedItem.Genres, StringComparer.Ordinal))
 2437                {
 2438                    newOptions.ForceSave = true;
 2439                    ownedItem.Genres = item.Genres;
 2440                }
 2441
 2442                if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal))
 2443                {
 2444                    newOptions.ForceSave = true;
 2445                    ownedItem.Studios = item.Studios;
 2446                }
 2447
 2448                if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal))
 2449                {
 2450                    newOptions.ForceSave = true;
 2451                    ownedItem.ProductionLocations = item.ProductionLocations;
 2452                }
 2453
 2454                if (item.CommunityRating != ownedItem.CommunityRating)
 2455                {
 2456                    ownedItem.CommunityRating = item.CommunityRating;
 2457                    newOptions.ForceSave = true;
 2458                }
 2459
 2460                if (item.CriticRating != ownedItem.CriticRating)
 2461                {
 2462                    ownedItem.CriticRating = item.CriticRating;
 2463                    newOptions.ForceSave = true;
 2464                }
 2465
 2466                if (!string.Equals(item.Overview, ownedItem.Overview, StringComparison.Ordinal))
 2467                {
 2468                    ownedItem.Overview = item.Overview;
 2469                    newOptions.ForceSave = true;
 2470                }
 2471
 2472                if (!string.Equals(item.OfficialRating, ownedItem.OfficialRating, StringComparison.Ordinal))
 2473                {
 2474                    ownedItem.OfficialRating = item.OfficialRating;
 2475                    newOptions.ForceSave = true;
 2476                }
 2477
 2478                if (!string.Equals(item.CustomRating, ownedItem.CustomRating, StringComparison.Ordinal))
 2479                {
 2480                    ownedItem.CustomRating = item.CustomRating;
 2481                    newOptions.ForceSave = true;
 2482                }
 2483            }
 2484
 2485            await ownedItem.RefreshMetadata(newOptions, cancellationToken).ConfigureAwait(false);
 2486        }
 2487
 2488        protected async Task RefreshMetadataForOwnedVideo(MetadataRefreshOptions options, bool copyTitleMetadata, string
 2489        {
 2490            var newOptions = new MetadataRefreshOptions(options)
 2491            {
 2492                SearchResult = null
 2493            };
 2494
 2495            var id = LibraryManager.GetNewItemId(path, typeof(Video));
 2496
 2497            // Try to retrieve it from the db. If we don't find it, use the resolved version
 2498            if (LibraryManager.GetItemById(id) is not Video video)
 2499            {
 2500                video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video;
 2501
 2502                newOptions.ForceSave = true;
 2503            }
 2504
 2505            if (video is null)
 2506            {
 2507                return;
 2508            }
 2509
 2510            if (video.OwnerId.IsEmpty())
 2511            {
 2512                video.OwnerId = Id;
 2513            }
 2514
 2515            await RefreshMetadataForOwnedItem(video, copyTitleMetadata, newOptions, cancellationToken).ConfigureAwait(fa
 2516        }
 2517
 2518        public string GetEtag(User user)
 2519        {
 62520            var list = GetEtagValues(user);
 2521
 62522            return string.Join('|', list).GetMD5().ToString("N", CultureInfo.InvariantCulture);
 2523        }
 2524
 2525        protected virtual List<string> GetEtagValues(User user)
 2526        {
 62527            return
 62528            [
 62529                DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture)
 62530            ];
 2531        }
 2532
 2533        public virtual IEnumerable<Guid> GetAncestorIds()
 2534        {
 1142535            return GetParents().Select(i => i.Id).Concat(LibraryManager.GetCollectionFolders(this).Select(i => i.Id));
 2536        }
 2537
 2538        public BaseItem GetTopParent()
 2539        {
 1142540            if (IsTopParent)
 2541            {
 212542                return this;
 2543            }
 2544
 932545            return GetParents().FirstOrDefault(parent => parent.IsTopParent);
 2546        }
 2547
 2548        public virtual IEnumerable<Guid> GetIdsForAncestorQuery()
 2549        {
 442550            return [Id];
 2551        }
 2552
 2553        public virtual double? GetRefreshProgress()
 2554        {
 02555            return null;
 2556        }
 2557
 2558        public virtual ItemUpdateType OnMetadataChanged()
 2559        {
 1102560            var updateType = ItemUpdateType.None;
 2561
 1102562            var item = this;
 2563
 1102564            var rating = item.GetParentalRatingScore();
 1102565            if (rating is not null)
 2566            {
 02567                if (rating.Score != item.InheritedParentalRatingValue)
 2568                {
 02569                    item.InheritedParentalRatingValue = rating.Score;
 02570                    updateType |= ItemUpdateType.MetadataImport;
 2571                }
 2572
 02573                if (rating.SubScore != item.InheritedParentalRatingSubValue)
 2574                {
 02575                    item.InheritedParentalRatingSubValue = rating.SubScore;
 02576                    updateType |= ItemUpdateType.MetadataImport;
 2577                }
 2578            }
 2579            else
 2580            {
 1102581                if (item.InheritedParentalRatingValue is not null)
 2582                {
 02583                    item.InheritedParentalRatingValue = null;
 02584                    item.InheritedParentalRatingSubValue = null;
 02585                    updateType |= ItemUpdateType.MetadataImport;
 2586                }
 2587            }
 2588
 1102589            return updateType;
 2590        }
 2591
 2592        /// <summary>
 2593        /// Updates the official rating based on content and returns true or false indicating if it changed.
 2594        /// </summary>
 2595        /// <param name="children">Media children.</param>
 2596        /// <returns><c>true</c> if the rating was updated; otherwise <c>false</c>.</returns>
 2597        public bool UpdateRatingToItems(IReadOnlyList<BaseItem> children)
 2598        {
 02599            var currentOfficialRating = OfficialRating;
 2600
 2601            // Gather all possible ratings
 02602            var ratings = children
 02603                .Select(i => i.OfficialRating)
 02604                .Where(i => !string.IsNullOrEmpty(i))
 02605                .Distinct(StringComparer.OrdinalIgnoreCase)
 02606                .Select(rating => (rating, LocalizationManager.GetRatingScore(rating)))
 02607                .OrderBy(i => i.Item2 is null ? 1001 : i.Item2.Score)
 02608                .ThenBy(i => i.Item2 is null ? 1001 : i.Item2.SubScore)
 02609                .Select(i => i.rating);
 2610
 02611            OfficialRating = ratings.FirstOrDefault() ?? currentOfficialRating;
 2612
 02613            return !string.Equals(
 02614                currentOfficialRating ?? string.Empty,
 02615                OfficialRating ?? string.Empty,
 02616                StringComparison.OrdinalIgnoreCase);
 2617        }
 2618
 2619        public IReadOnlyList<BaseItem> GetThemeSongs(User user = null)
 2620        {
 02621            return GetThemeSongs(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2622        }
 2623
 2624        public IReadOnlyList<BaseItem> GetThemeSongs(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> or
 2625        {
 02626            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeSong), user, 
 2627        }
 2628
 2629        public IReadOnlyList<BaseItem> GetThemeVideos(User user = null)
 2630        {
 02631            return GetThemeVideos(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2632        }
 2633
 2634        public IReadOnlyList<BaseItem> GetThemeVideos(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> o
 2635        {
 02636            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeVideo), user,
 2637        }
 2638
 2639        /// <summary>
 2640        /// Get all extras associated with this item, sorted by <see cref="SortName"/>.
 2641        /// </summary>
 2642        /// <returns>An enumerable containing the items.</returns>
 2643        public IEnumerable<BaseItem> GetExtras()
 2644        {
 62645            return ExtraIds
 62646                .Select(LibraryManager.GetItemById)
 62647                .Where(i => i is not null)
 62648                .OrderBy(i => i.SortName);
 2649        }
 2650
 2651        /// <summary>
 2652        /// Get all extras with specific types that are associated with this item.
 2653        /// </summary>
 2654        /// <param name="extraTypes">The types of extras to retrieve.</param>
 2655        /// <returns>An enumerable containing the extras.</returns>
 2656        public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
 2657        {
 02658            return ExtraIds
 02659                .Select(LibraryManager.GetItemById)
 02660                .Where(i => i is not null)
 02661                .Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value))
 02662                .OrderBy(i => i.SortName);
 2663        }
 2664
 2665        public virtual long GetRunTimeTicksForPlayState()
 2666        {
 02667            return RunTimeTicks ?? 0;
 2668        }
 2669
 2670        /// <inheritdoc />
 2671        public override bool Equals(object obj)
 2672        {
 02673            return obj is BaseItem baseItem && this.Equals(baseItem);
 2674        }
 2675
 2676        /// <inheritdoc />
 62677        public bool Equals(BaseItem other) => other is not null && other.Id.Equals(Id);
 2678
 2679        /// <inheritdoc />
 632680        public override int GetHashCode() => HashCode.Combine(Id);
 2681    }
 2682}

Methods/Properties

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