< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.BaseItem
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/BaseItem.cs
Line coverage
48%
Covered lines: 371
Uncovered lines: 388
Coverable lines: 759
Total lines: 2611
Line coverage: 48.8%
Branch coverage
39%
Covered branches: 177
Total branches: 448
Branch coverage: 39.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor()100%11100%
get_SupportsAddingToPlaylist()100%210%
get_AlwaysScanInternalMetadataPath()100%11100%
get_SupportsPlayedStatus()100%210%
get_SupportsPositionTicksResume()100%210%
get_SupportsRemoteImageDownloading()100%11100%
get_Name()100%11100%
set_Name(...)100%11100%
get_IsUnaired()0%620%
get_IsThemeMedia()0%2040%
get_DisplayPreferencesId()50%22100%
get_SourceType()50%2.15266.66%
get_ContainingFolderPath()50%2.15266.66%
get_IsHidden()100%210%
get_LocationType()33.33%10.5650%
get_PathProtocol()100%22100%
get_IsFileProtocol()100%11100%
get_HasPathProtocol()100%210%
get_SupportsLocalMetadata()50%2.15266.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%2.15266.66%
get_ForcedSortName()100%11100%
set_ForcedSortName(...)100%11100%
get_SortName()75%4.13480%
set_SortName(...)100%11100%
get_DisplayParentId()100%11100%
get_DisplayParent()100%22100%
get_HasLocalAlternateVersions()100%210%
get_OfficialRatingForComparison()75%4.05485.71%
get_CustomRatingForComparison()75%4.05485.71%
get_LatestItemsIndexContainer()100%210%
get_EnableRememberingTrackSelections()100%210%
get_IsTopParent()80%11.561075%
get_SupportsAncestors()100%11100%
get_SupportsOwnedItems()100%22100%
get_SupportsPeople()100%11100%
get_SupportsThemeMedia()100%210%
get_SupportsInheritedParentImages()100%210%
get_IsFolder()100%11100%
get_IsDisplayedAsFolder()100%210%
GetDefaultPrimaryImageAspectRatio()100%210%
CreatePresentationUniqueKey()100%11100%
CanDelete()0%620%
IsAuthorizedToDelete(...)0%7280%
GetOwner()50%22100%
CanDelete(...)50%22100%
CanDelete(...)100%11100%
CanDownload()100%11100%
IsAuthorizedToDownload(...)100%210%
CanDownload(...)50%22100%
ToString()100%11100%
GetInternalMetadataPath()100%11100%
GetInternalMetadataPath(...)50%2.06275%
CreateSortName()71.42%17.061475%
ModifySortChunks(...)87.5%8.02893.75%
GetParent()100%22100%
FindParent()0%2040%
GetPlayAccess(...)50%2.15266.66%
GetMediaStreams()100%210%
IsActiveRecording()100%210%
GetMediaSources(...)0%7280%
GetAllItemsForMediaSources()100%210%
GetVersionInfo(...)0%1806420%
GetMediaSourceName(...)68.75%74.013265.51%
RefreshMetadata(...)100%11100%
IsVisibleStandaloneInternal(...)0%210140%
SetParent(...)100%22100%
GetFileSystemChildren(...)100%11100%
GetPresentationUniqueKey()0%620%
RequiresRefresh()100%11100%
GetUserDataKeys()50%4.59466.66%
UpdateFromResolvedItem(...)50%2.26260%
AfterMetadataRefresh()100%11100%
GetPreferredMetadataLanguage()100%88100%
GetPreferredMetadataCountryCode()100%88100%
IsSaveLocalMetadataEnabled()50%2.06275%
IsParentalAllowed(...)33.33%27.011252.94%
GetInheritedParentalRatingValue()75%4.07483.33%
GetInheritedTags()75%4.05485.71%
IsVisibleViaTags(...)42.85%38.51450%
GetBlockUnratedType()50%2.15266.66%
GetBlockUnratedValue(...)50%4.59466.66%
IsVisible(...)100%11100%
IsVisibleStandalone(...)0%2040%
GetClientTypeName()83.33%7.33666.66%
GetBaseItemKind()100%22100%
GetLinkedChild(...)0%7280%
FindLinkedChild(...)0%7280%
AddStudio(...)50%4.25475%
SetStudios(...)100%210%
AddGenre(...)100%22100%
MarkPlayed(...)0%7280%
MarkUnplayed(...)100%210%
ChangedExternally()100%210%
HasImage(...)100%11100%
SetImage(...)75%4.01490.9%
SetImagePath(...)75%4.01490.9%
RemoveImage(...)100%210%
RemoveImages(...)100%11100%
AddImage(...)100%11100%
UpdateToRepositoryAsync(...)100%11100%
ValidateImages()100%1212100%
GetImagePath(...)50%22100%
GetImageInfo(...)33.33%82.861221.05%
GetImageIndex(...)0%110100%
AddImages(...)85%20.262091.3%
GetImageInfo(...)100%11100%
GetDeletePaths()100%210%
GetLocalMetadataFilesToDelete()0%2040%
AllowsMultipleImages(...)100%22100%
SwapImagesAsync(...)0%110100%
IsPlayed(...)0%620%
IsFavoriteOrLiked(...)0%2040%
IsUnplayed(...)0%620%
MediaBrowser.Controller.Providers.IHasLookupInfo<MediaBrowser.Controller.Providers.ItemLookupInfo>.GetLookupInfo()100%11100%
GetItemLookupInfo()100%11100%
GetNameForMetadataLookup()100%11100%
BeforeMetadataRefresh(...)50%4.59466.66%
GetMappedPath(...)0%620%
FillUserDataDtoValues(...)0%4260%
RefreshMetadataForOwnedItem(...)0%342180%
RefreshMetadataForOwnedVideo(...)0%4260%
GetEtag(...)100%11100%
GetEtagValues(...)100%11100%
GetAncestorIds()100%11100%
GetTopParent()100%22100%
GetIdsForAncestorQuery()100%11100%
GetRefreshProgress()100%210%
OnMetadataChanged()50%4.37471.42%
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.Globalization;
 8using System.IO;
 9using System.Linq;
 10using System.Text;
 11using System.Text.Json.Serialization;
 12using System.Threading;
 13using System.Threading.Tasks;
 14using Jellyfin.Data.Entities;
 15using Jellyfin.Data.Enums;
 16using Jellyfin.Extensions;
 17using MediaBrowser.Common.Extensions;
 18using MediaBrowser.Controller.Channels;
 19using MediaBrowser.Controller.Configuration;
 20using MediaBrowser.Controller.Dto;
 21using MediaBrowser.Controller.Entities.Audio;
 22using MediaBrowser.Controller.Library;
 23using MediaBrowser.Controller.Persistence;
 24using MediaBrowser.Controller.Providers;
 25using MediaBrowser.Model.Dto;
 26using MediaBrowser.Model.Entities;
 27using MediaBrowser.Model.Globalization;
 28using MediaBrowser.Model.IO;
 29using MediaBrowser.Model.Library;
 30using MediaBrowser.Model.LiveTv;
 31using MediaBrowser.Model.MediaInfo;
 32using MediaBrowser.Model.Providers;
 33using Microsoft.Extensions.Logging;
 34
 35namespace MediaBrowser.Controller.Entities
 36{
 37    /// <summary>
 38    /// Class BaseItem.
 39    /// </summary>
 40    public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo>, IEquatable<BaseItem>
 41    {
 42        private BaseItemKind? _baseItemKind;
 43
 44        public const string ThemeSongFileName = "theme";
 45
 46        /// <summary>
 47        /// The supported image extensions.
 48        /// </summary>
 449        public static readonly string[] SupportedImageExtensions
 450            = new[] { ".png", ".jpg", ".jpeg", ".webp", ".tbn", ".gif", ".svg" };
 51
 452        private static readonly List<string> _supportedExtensions = new List<string>(SupportedImageExtensions)
 453        {
 454            ".nfo",
 455            ".xml",
 456            ".srt",
 457            ".vtt",
 458            ".sub",
 459            ".sup",
 460            ".idx",
 461            ".txt",
 462            ".edl",
 463            ".bif",
 464            ".smi",
 465            ".ttml",
 466            ".lrc",
 467            ".elrc"
 468        };
 69
 70        /// <summary>
 71        /// Extra types that should be counted and displayed as "Special Features" in the UI.
 72        /// </summary>
 473        public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new HashSet<ExtraType>
 474        {
 475            Model.Entities.ExtraType.Unknown,
 476            Model.Entities.ExtraType.BehindTheScenes,
 477            Model.Entities.ExtraType.Clip,
 478            Model.Entities.ExtraType.DeletedScene,
 479            Model.Entities.ExtraType.Interview,
 480            Model.Entities.ExtraType.Sample,
 481            Model.Entities.ExtraType.Scene,
 482            Model.Entities.ExtraType.Featurette,
 483            Model.Entities.ExtraType.Short
 484        };
 85
 86        private string _sortName;
 87
 88        private string _forcedSortName;
 89
 90        private string _name;
 91
 92        public const char SlugChar = '-';
 93
 94        protected BaseItem()
 95        {
 95496            Tags = Array.Empty<string>();
 95497            Genres = Array.Empty<string>();
 95498            Studios = Array.Empty<string>();
 95499            ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 954100            LockedFields = Array.Empty<MetadataField>();
 954101            ImageInfos = Array.Empty<ItemImageInfo>();
 954102            ProductionLocations = Array.Empty<string>();
 954103            RemoteTrailers = Array.Empty<MediaUrl>();
 954104            ExtraIds = Array.Empty<Guid>();
 954105        }
 106
 107        [JsonIgnore]
 108        public string PreferredMetadataCountryCode { get; set; }
 109
 110        [JsonIgnore]
 111        public string PreferredMetadataLanguage { get; set; }
 112
 113        public long? Size { get; set; }
 114
 115        public string Container { get; set; }
 116
 117        [JsonIgnore]
 118        public string Tagline { get; set; }
 119
 120        [JsonIgnore]
 121        public virtual ItemImageInfo[] ImageInfos { get; set; }
 122
 123        [JsonIgnore]
 124        public bool IsVirtualItem { get; set; }
 125
 126        /// <summary>
 127        /// Gets or sets the album.
 128        /// </summary>
 129        /// <value>The album.</value>
 130        [JsonIgnore]
 131        public string Album { get; set; }
 132
 133        /// <summary>
 134        /// Gets or sets the LUFS value.
 135        /// </summary>
 136        /// <value>The LUFS Value.</value>
 137        [JsonIgnore]
 138        public float? LUFS { get; set; }
 139
 140        /// <summary>
 141        /// Gets or sets the gain required for audio normalization.
 142        /// </summary>
 143        /// <value>The gain required for audio normalization.</value>
 144        [JsonIgnore]
 145        public float? NormalizationGain { get; set; }
 146
 147        /// <summary>
 148        /// Gets or sets the channel identifier.
 149        /// </summary>
 150        /// <value>The channel identifier.</value>
 151        [JsonIgnore]
 152        public Guid ChannelId { get; set; }
 153
 154        [JsonIgnore]
 0155        public virtual bool SupportsAddingToPlaylist => false;
 156
 157        [JsonIgnore]
 4158        public virtual bool AlwaysScanInternalMetadataPath => false;
 159
 160        /// <summary>
 161        /// Gets or sets a value indicating whether this instance is in mixed folder.
 162        /// </summary>
 163        /// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
 164        [JsonIgnore]
 165        public bool IsInMixedFolder { get; set; }
 166
 167        [JsonIgnore]
 0168        public virtual bool SupportsPlayedStatus => false;
 169
 170        [JsonIgnore]
 0171        public virtual bool SupportsPositionTicksResume => false;
 172
 173        [JsonIgnore]
 17174        public virtual bool SupportsRemoteImageDownloading => true;
 175
 176        /// <summary>
 177        /// Gets or sets the name.
 178        /// </summary>
 179        /// <value>The name.</value>
 180        [JsonIgnore]
 181        public virtual string Name
 182        {
 957183            get => _name;
 184            set
 185            {
 372186                _name = value;
 187
 188                // lazy load this again
 372189                _sortName = null;
 372190            }
 191        }
 192
 193        [JsonIgnore]
 0194        public bool IsUnaired => PremiereDate.HasValue && PremiereDate.Value.ToLocalTime().Date >= DateTime.Now.Date;
 195
 196        [JsonIgnore]
 197        public int? TotalBitrate { get; set; }
 198
 199        [JsonIgnore]
 200        public ExtraType? ExtraType { get; set; }
 201
 202        [JsonIgnore]
 0203        public bool IsThemeMedia => ExtraType.HasValue && (ExtraType.Value == Model.Entities.ExtraType.ThemeSong || Extr
 204
 205        [JsonIgnore]
 206        public string OriginalTitle { get; set; }
 207
 208        /// <summary>
 209        /// Gets or sets the id.
 210        /// </summary>
 211        /// <value>The id.</value>
 212        [JsonIgnore]
 213        public Guid Id { get; set; }
 214
 215        [JsonIgnore]
 216        public Guid OwnerId { get; set; }
 217
 218        /// <summary>
 219        /// Gets or sets the audio.
 220        /// </summary>
 221        /// <value>The audio.</value>
 222        [JsonIgnore]
 223        public ProgramAudio? Audio { get; set; }
 224
 225        /// <summary>
 226        /// Gets the id that should be used to key display prefs for this item.
 227        /// Default is based on the type for everything except actual generic folders.
 228        /// </summary>
 229        /// <value>The display prefs id.</value>
 230        [JsonIgnore]
 231        public virtual Guid DisplayPreferencesId
 232        {
 233            get
 234            {
 11235                var thisType = GetType();
 11236                return thisType == typeof(Folder) ? Id : thisType.FullName.GetMD5();
 237            }
 238        }
 239
 240        /// <summary>
 241        /// Gets or sets the path.
 242        /// </summary>
 243        /// <value>The path.</value>
 244        [JsonIgnore]
 245        public virtual string Path { get; set; }
 246
 247        [JsonIgnore]
 248        public virtual SourceType SourceType
 249        {
 250            get
 251            {
 1465252                if (!ChannelId.IsEmpty())
 253                {
 0254                    return SourceType.Channel;
 255                }
 256
 1465257                return SourceType.Library;
 258            }
 259        }
 260
 261        /// <summary>
 262        /// Gets the folder containing the item.
 263        /// If the item is a folder, it returns the folder itself.
 264        /// </summary>
 265        [JsonIgnore]
 266        public virtual string ContainingFolderPath
 267        {
 268            get
 269            {
 403270                if (IsFolder)
 271                {
 358272                    return Path;
 273                }
 274
 45275                return System.IO.Path.GetDirectoryName(Path);
 276            }
 277        }
 278
 279        /// <summary>
 280        /// Gets or sets the name of the service.
 281        /// </summary>
 282        /// <value>The name of the service.</value>
 283        [JsonIgnore]
 284        public string ServiceName { get; set; }
 285
 286        /// <summary>
 287        /// Gets or sets the external id.
 288        /// </summary>
 289        /// <remarks>
 290        /// If this content came from an external service, the id of the content on that service.
 291        /// </remarks>
 292        [JsonIgnore]
 293        public string ExternalId { get; set; }
 294
 295        [JsonIgnore]
 296        public string ExternalSeriesId { get; set; }
 297
 298        [JsonIgnore]
 0299        public virtual bool IsHidden => false;
 300
 301        /// <summary>
 302        /// Gets the type of the location.
 303        /// </summary>
 304        /// <value>The type of the location.</value>
 305        [JsonIgnore]
 306        public virtual LocationType LocationType
 307        {
 308            get
 309            {
 14310                var path = Path;
 14311                if (string.IsNullOrEmpty(path))
 312                {
 0313                    if (SourceType == SourceType.Channel)
 314                    {
 0315                        return LocationType.Remote;
 316                    }
 317
 0318                    return LocationType.Virtual;
 319                }
 320
 14321                return FileSystem.IsPathFile(path) ? LocationType.FileSystem : LocationType.Remote;
 322            }
 323        }
 324
 325        [JsonIgnore]
 326        public MediaProtocol? PathProtocol
 327        {
 328            get
 329            {
 1904330                var path = Path;
 331
 1904332                if (string.IsNullOrEmpty(path))
 333                {
 116334                    return null;
 335                }
 336
 1788337                return MediaSourceManager.GetPathProtocol(path);
 338            }
 339        }
 340
 341        [JsonIgnore]
 1883342        public bool IsFileProtocol => PathProtocol == MediaProtocol.File;
 343
 344        [JsonIgnore]
 0345        public bool HasPathProtocol => PathProtocol.HasValue;
 346
 347        [JsonIgnore]
 348        public virtual bool SupportsLocalMetadata
 349        {
 350            get
 351            {
 932352                if (SourceType == SourceType.Channel)
 353                {
 0354                    return false;
 355                }
 356
 932357                return IsFileProtocol;
 358            }
 359        }
 360
 361        [JsonIgnore]
 362        public virtual string FileNameWithoutExtension
 363        {
 364            get
 365            {
 0366                if (IsFileProtocol)
 367                {
 0368                    return System.IO.Path.GetFileNameWithoutExtension(Path);
 369                }
 370
 0371                return null;
 372            }
 373        }
 374
 375        [JsonIgnore]
 104376        public virtual bool EnableAlphaNumericSorting => true;
 377
 49378        public virtual bool IsHD => Height >= 720;
 379
 380        public bool IsShortcut { get; set; }
 381
 382        public string ShortcutPath { get; set; }
 383
 384        public int Width { get; set; }
 385
 386        public int Height { get; set; }
 387
 388        public Guid[] ExtraIds { get; set; }
 389
 390        /// <summary>
 391        /// Gets the primary image path.
 392        /// </summary>
 393        /// <remarks>
 394        /// This is just a helper for convenience.
 395        /// </remarks>
 396        /// <value>The primary image path.</value>
 397        [JsonIgnore]
 0398        public string PrimaryImagePath => this.GetImagePath(ImageType.Primary);
 399
 400        /// <summary>
 401        /// Gets or sets the date created.
 402        /// </summary>
 403        /// <value>The date created.</value>
 404        [JsonIgnore]
 405        public DateTime DateCreated { get; set; }
 406
 407        /// <summary>
 408        /// Gets or sets the date modified.
 409        /// </summary>
 410        /// <value>The date modified.</value>
 411        [JsonIgnore]
 412        public DateTime DateModified { get; set; }
 413
 414        public DateTime DateLastSaved { get; set; }
 415
 416        [JsonIgnore]
 417        public DateTime DateLastRefreshed { get; set; }
 418
 419        [JsonIgnore]
 420        public bool IsLocked { get; set; }
 421
 422        /// <summary>
 423        /// Gets or sets the locked fields.
 424        /// </summary>
 425        /// <value>The locked fields.</value>
 426        [JsonIgnore]
 427        public MetadataField[] LockedFields { get; set; }
 428
 429        /// <summary>
 430        /// Gets the type of the media.
 431        /// </summary>
 432        /// <value>The type of the media.</value>
 433        [JsonIgnore]
 73434        public virtual MediaType MediaType => MediaType.Unknown;
 435
 436        [JsonIgnore]
 437        public virtual string[] PhysicalLocations
 438        {
 439            get
 440            {
 0441                if (!IsFileProtocol)
 442                {
 0443                    return Array.Empty<string>();
 444                }
 445
 0446                return new[] { Path };
 447            }
 448        }
 449
 450        [JsonIgnore]
 451        public bool EnableMediaSourceDisplay
 452        {
 453            get
 454            {
 11455                if (SourceType == SourceType.Channel)
 456                {
 0457                    return ChannelManager.EnableMediaSourceDisplay(this);
 458                }
 459
 11460                return true;
 461            }
 462        }
 463
 464        [JsonIgnore]
 465        public Guid ParentId { get; set; }
 466
 467        /// <summary>
 468        /// Gets or sets the logger.
 469        /// </summary>
 470        public static ILogger<BaseItem> Logger { get; set; }
 471
 472        public static ILibraryManager LibraryManager { get; set; }
 473
 474        public static IServerConfigurationManager ConfigurationManager { get; set; }
 475
 476        public static IProviderManager ProviderManager { get; set; }
 477
 478        public static ILocalizationManager LocalizationManager { get; set; }
 479
 480        public static IItemRepository ItemRepository { get; set; }
 481
 482        public static IFileSystem FileSystem { get; set; }
 483
 484        public static IUserDataManager UserDataManager { get; set; }
 485
 486        public static IChannelManager ChannelManager { get; set; }
 487
 488        public static IMediaSourceManager MediaSourceManager { get; set; }
 489
 490        public static IMediaSegmentManager MediaSegmentManager { get; set; }
 491
 492        /// <summary>
 493        /// Gets or sets the name of the forced sort.
 494        /// </summary>
 495        /// <value>The name of the forced sort.</value>
 496        [JsonIgnore]
 497        public string ForcedSortName
 498        {
 421499            get => _forcedSortName;
 500            set
 501            {
 15502                _forcedSortName = value;
 15503                _sortName = null;
 15504            }
 505        }
 506
 507        /// <summary>
 508        /// Gets or sets the name of the sort.
 509        /// </summary>
 510        /// <value>The name of the sort.</value>
 511        [JsonIgnore]
 512        public string SortName
 513        {
 514            get
 515            {
 115516                if (_sortName is null)
 517                {
 104518                    if (!string.IsNullOrEmpty(ForcedSortName))
 519                    {
 520                        // Need the ToLower because that's what CreateSortName does
 0521                        _sortName = ModifySortChunks(ForcedSortName).ToLowerInvariant();
 522                    }
 523                    else
 524                    {
 104525                        _sortName = CreateSortName();
 526                    }
 527                }
 528
 115529                return _sortName;
 530            }
 531
 46532            set => _sortName = value;
 533        }
 534
 535        [JsonIgnore]
 183536        public virtual Guid DisplayParentId => ParentId;
 537
 538        [JsonIgnore]
 539        public BaseItem DisplayParent
 540        {
 541            get
 542            {
 172543                var id = DisplayParentId;
 172544                if (id.IsEmpty())
 545                {
 128546                    return null;
 547                }
 548
 44549                return LibraryManager.GetItemById(id);
 550            }
 551        }
 552
 553        /// <summary>
 554        /// Gets or sets the date that the item first debuted. For movies this could be premiere date, episodes would be
 555        /// </summary>
 556        /// <value>The premiere date.</value>
 557        [JsonIgnore]
 558        public DateTime? PremiereDate { get; set; }
 559
 560        /// <summary>
 561        /// Gets or sets the end date.
 562        /// </summary>
 563        /// <value>The end date.</value>
 564        [JsonIgnore]
 565        public DateTime? EndDate { get; set; }
 566
 567        /// <summary>
 568        /// Gets or sets the official rating.
 569        /// </summary>
 570        /// <value>The official rating.</value>
 571        [JsonIgnore]
 572        public string OfficialRating { get; set; }
 573
 574        [JsonIgnore]
 575        public int? InheritedParentalRatingValue { get; set; }
 576
 577        /// <summary>
 578        /// Gets or sets the critic rating.
 579        /// </summary>
 580        /// <value>The critic rating.</value>
 581        [JsonIgnore]
 582        public float? CriticRating { get; set; }
 583
 584        /// <summary>
 585        /// Gets or sets the custom rating.
 586        /// </summary>
 587        /// <value>The custom rating.</value>
 588        [JsonIgnore]
 589        public string CustomRating { get; set; }
 590
 591        /// <summary>
 592        /// Gets or sets the overview.
 593        /// </summary>
 594        /// <value>The overview.</value>
 595        [JsonIgnore]
 596        public string Overview { get; set; }
 597
 598        /// <summary>
 599        /// Gets or sets the studios.
 600        /// </summary>
 601        /// <value>The studios.</value>
 602        [JsonIgnore]
 603        public string[] Studios { get; set; }
 604
 605        /// <summary>
 606        /// Gets or sets the genres.
 607        /// </summary>
 608        /// <value>The genres.</value>
 609        [JsonIgnore]
 610        public string[] Genres { get; set; }
 611
 612        /// <summary>
 613        /// Gets or sets the tags.
 614        /// </summary>
 615        /// <value>The tags.</value>
 616        [JsonIgnore]
 617        public string[] Tags { get; set; }
 618
 619        [JsonIgnore]
 620        public string[] ProductionLocations { get; set; }
 621
 622        /// <summary>
 623        /// Gets or sets the home page URL.
 624        /// </summary>
 625        /// <value>The home page URL.</value>
 626        [JsonIgnore]
 627        public string HomePageUrl { get; set; }
 628
 629        /// <summary>
 630        /// Gets or sets the community rating.
 631        /// </summary>
 632        /// <value>The community rating.</value>
 633        [JsonIgnore]
 634        public float? CommunityRating { get; set; }
 635
 636        /// <summary>
 637        /// Gets or sets the run time ticks.
 638        /// </summary>
 639        /// <value>The run time ticks.</value>
 640        [JsonIgnore]
 641        public long? RunTimeTicks { get; set; }
 642
 643        /// <summary>
 644        /// Gets or sets the production year.
 645        /// </summary>
 646        /// <value>The production year.</value>
 647        [JsonIgnore]
 648        public int? ProductionYear { get; set; }
 649
 650        /// <summary>
 651        /// Gets or sets the index number. If the item is part of a series, this is it's number in the series.
 652        /// This could be episode number, album track number, etc.
 653        /// </summary>
 654        /// <value>The index number.</value>
 655        [JsonIgnore]
 656        public int? IndexNumber { get; set; }
 657
 658        /// <summary>
 659        /// Gets or sets the parent index number. For an episode this could be the season number, or for a song this cou
 660        /// </summary>
 661        /// <value>The parent index number.</value>
 662        [JsonIgnore]
 663        public int? ParentIndexNumber { get; set; }
 664
 665        [JsonIgnore]
 0666        public virtual bool HasLocalAlternateVersions => false;
 667
 668        [JsonIgnore]
 669        public string OfficialRatingForComparison
 670        {
 671            get
 672            {
 86673                var officialRating = OfficialRating;
 86674                if (!string.IsNullOrEmpty(officialRating))
 675                {
 0676                    return officialRating;
 677                }
 678
 86679                var parent = DisplayParent;
 86680                if (parent is not null)
 681                {
 22682                    return parent.OfficialRatingForComparison;
 683                }
 684
 64685                return null;
 686            }
 687        }
 688
 689        [JsonIgnore]
 690        public string CustomRatingForComparison
 691        {
 692            get
 693            {
 86694                var customRating = CustomRating;
 86695                if (!string.IsNullOrEmpty(customRating))
 696                {
 0697                    return customRating;
 698                }
 699
 86700                var parent = DisplayParent;
 86701                if (parent is not null)
 702                {
 22703                    return parent.CustomRatingForComparison;
 704                }
 705
 64706                return null;
 707            }
 708        }
 709
 710        /// <summary>
 711        /// Gets or sets the provider ids.
 712        /// </summary>
 713        /// <value>The provider ids.</value>
 714        [JsonIgnore]
 715        public Dictionary<string, string> ProviderIds { get; set; }
 716
 717        [JsonIgnore]
 0718        public virtual Folder LatestItemsIndexContainer => null;
 719
 720        [JsonIgnore]
 721        public string PresentationUniqueKey { get; set; }
 722
 723        [JsonIgnore]
 0724        public virtual bool EnableRememberingTrackSelections => true;
 725
 726        [JsonIgnore]
 727        public virtual bool IsTopParent
 728        {
 729            get
 730            {
 213731                if (this is BasePluginFolder || this is Channel)
 732                {
 62733                    return true;
 734                }
 735
 151736                if (this is IHasCollectionType view)
 737                {
 4738                    if (view.CollectionType == CollectionType.livetv)
 739                    {
 0740                        return true;
 741                    }
 742                }
 743
 151744                if (GetParent() is AggregateFolder)
 745                {
 0746                    return true;
 747                }
 748
 151749                return false;
 750            }
 751        }
 752
 753        [JsonIgnore]
 118754        public virtual bool SupportsAncestors => true;
 755
 756        [JsonIgnore]
 71757        protected virtual bool SupportsOwnedItems => !ParentId.IsEmpty() && IsFileProtocol;
 758
 759        [JsonIgnore]
 88760        public virtual bool SupportsPeople => false;
 761
 762        [JsonIgnore]
 0763        public virtual bool SupportsThemeMedia => false;
 764
 765        [JsonIgnore]
 0766        public virtual bool SupportsInheritedParentImages => false;
 767
 768        /// <summary>
 769        /// Gets a value indicating whether this instance is folder.
 770        /// </summary>
 771        /// <value><c>true</c> if this instance is folder; otherwise, <c>false</c>.</value>
 772        [JsonIgnore]
 65773        public virtual bool IsFolder => false;
 774
 775        [JsonIgnore]
 0776        public virtual bool IsDisplayedAsFolder => false;
 777
 778        /// <summary>
 779        /// Gets or sets the remote trailers.
 780        /// </summary>
 781        /// <value>The remote trailers.</value>
 782        public IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
 783
 784        public virtual double GetDefaultPrimaryImageAspectRatio()
 785        {
 0786            return 0;
 787        }
 788
 789        public virtual string CreatePresentationUniqueKey()
 790        {
 46791            return Id.ToString("N", CultureInfo.InvariantCulture);
 792        }
 793
 794        public virtual bool CanDelete()
 795        {
 0796            if (SourceType == SourceType.Channel)
 797            {
 0798                return ChannelManager.CanDelete(this);
 799            }
 800
 0801            return IsFileProtocol;
 802        }
 803
 804        public virtual bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
 805        {
 0806            if (user.HasPermission(PermissionKind.EnableContentDeletion))
 807            {
 0808                return true;
 809            }
 810
 0811            var allowed = user.GetPreferenceValues<Guid>(PreferenceKind.EnableContentDeletionFromFolders);
 812
 0813            if (SourceType == SourceType.Channel)
 814            {
 0815                return allowed.Contains(ChannelId);
 816            }
 817
 0818            var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
 819
 0820            foreach (var folder in collectionFolders)
 821            {
 0822                if (allowed.Contains(folder.Id))
 823                {
 0824                    return true;
 825                }
 826            }
 827
 0828            return false;
 0829        }
 830
 831        public BaseItem GetOwner()
 832        {
 580833            var ownerId = OwnerId;
 580834            return ownerId.IsEmpty() ? null : LibraryManager.GetItemById(ownerId);
 835        }
 836
 837        public bool CanDelete(User user, List<Folder> allCollectionFolders)
 838        {
 11839            return CanDelete() && IsAuthorizedToDelete(user, allCollectionFolders);
 840        }
 841
 842        public virtual bool CanDelete(User user)
 843        {
 11844            var allCollectionFolders = LibraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
 845
 11846            return CanDelete(user, allCollectionFolders);
 847        }
 848
 849        public virtual bool CanDownload()
 850        {
 11851            return false;
 852        }
 853
 854        public virtual bool IsAuthorizedToDownload(User user)
 855        {
 0856            return user.HasPermission(PermissionKind.EnableContentDownloading);
 857        }
 858
 859        public bool CanDownload(User user)
 860        {
 11861            return CanDownload() && IsAuthorizedToDownload(user);
 862        }
 863
 864        /// <inheritdoc />
 865        public override string ToString()
 866        {
 69867            return Name;
 868        }
 869
 870        public virtual string GetInternalMetadataPath()
 871        {
 72872            var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath;
 873
 72874            return GetInternalMetadataPath(basePath);
 875        }
 876
 877        protected virtual string GetInternalMetadataPath(string basePath)
 878        {
 72879            if (SourceType == SourceType.Channel)
 880            {
 0881                return System.IO.Path.Join(basePath, "channels", ChannelId.ToString("N", CultureInfo.InvariantCulture), 
 882            }
 883
 72884            ReadOnlySpan<char> idString = Id.ToString("N", CultureInfo.InvariantCulture);
 885
 72886            return System.IO.Path.Join(basePath, "library", idString[..2], idString);
 887        }
 888
 889        /// <summary>
 890        /// Creates the name of the sort.
 891        /// </summary>
 892        /// <returns>System.String.</returns>
 893        protected virtual string CreateSortName()
 894        {
 104895            if (Name is null)
 896            {
 0897                return null; // some items may not have name filled in properly
 898            }
 899
 104900            if (!EnableAlphaNumericSorting)
 901            {
 0902                return Name.TrimStart();
 903            }
 904
 104905            var sortable = Name.Trim().ToLowerInvariant();
 906
 832907            foreach (var search in ConfigurationManager.Configuration.SortRemoveWords)
 908            {
 909                // Remove from beginning if a space follows
 312910                if (sortable.StartsWith(search + " ", StringComparison.Ordinal))
 911                {
 0912                    sortable = sortable.Remove(0, search.Length + 1);
 913                }
 914
 915                // Remove from middle if surrounded by spaces
 312916                sortable = sortable.Replace(" " + search + " ", " ", StringComparison.Ordinal);
 917
 918                // Remove from end if followed by a space
 312919                if (sortable.EndsWith(" " + search, StringComparison.Ordinal))
 920                {
 0921                    sortable = sortable.Remove(sortable.Length - (search.Length + 1));
 922                }
 923            }
 924
 1456925            foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters)
 926            {
 624927                sortable = sortable.Replace(removeChar, string.Empty, StringComparison.Ordinal);
 928            }
 929
 832930            foreach (var replaceChar in ConfigurationManager.Configuration.SortReplaceCharacters)
 931            {
 312932                sortable = sortable.Replace(replaceChar, " ", StringComparison.Ordinal);
 933            }
 934
 104935            return ModifySortChunks(sortable);
 936        }
 937
 938        internal static string ModifySortChunks(ReadOnlySpan<char> name)
 939        {
 940            static void AppendChunk(StringBuilder builder, bool isDigitChunk, ReadOnlySpan<char> chunk)
 941            {
 942                if (isDigitChunk && chunk.Length < 10)
 943                {
 944                    builder.Append('0', 10 - chunk.Length);
 945                }
 946
 947                builder.Append(chunk);
 948            }
 949
 110950            if (name.IsEmpty)
 951            {
 1952                return string.Empty;
 953            }
 954
 109955            var builder = new StringBuilder(name.Length);
 956
 109957            int chunkStart = 0;
 109958            bool isDigitChunk = char.IsDigit(name[0]);
 1762959            for (int i = 0; i < name.Length; i++)
 960            {
 772961                var isDigit = char.IsDigit(name[i]);
 772962                if (isDigit != isDigitChunk)
 963                {
 3964                    AppendChunk(builder, isDigitChunk, name.Slice(chunkStart, i - chunkStart));
 3965                    chunkStart = i;
 3966                    isDigitChunk = isDigit;
 967                }
 968            }
 969
 109970            AppendChunk(builder, isDigitChunk, name.Slice(chunkStart));
 971
 972            // logger.LogDebug("ModifySortChunks Start: {0} End: {1}", name, builder.ToString());
 109973            var result = builder.ToString().RemoveDiacritics();
 109974            if (!result.All(char.IsAscii))
 975            {
 0976                result = result.Transliterated();
 977            }
 978
 109979            return result;
 980        }
 981
 982        public BaseItem GetParent()
 983        {
 1294984            var parentId = ParentId;
 1294985            if (parentId.IsEmpty())
 986            {
 1049987                return null;
 988            }
 989
 245990            return LibraryManager.GetItemById(parentId);
 991        }
 992
 993        public IEnumerable<BaseItem> GetParents()
 994        {
 995            var parent = GetParent();
 996
 997            while (parent is not null)
 998            {
 999                yield return parent;
 1000
 1001                parent = parent.GetParent();
 1002            }
 1003        }
 1004
 1005        /// <summary>
 1006        /// Finds a parent of a given type.
 1007        /// </summary>
 1008        /// <typeparam name="T">Type of parent.</typeparam>
 1009        /// <returns>``0.</returns>
 1010        public T FindParent<T>()
 1011            where T : Folder
 1012        {
 01013            foreach (var parent in GetParents())
 1014            {
 01015                if (parent is T item)
 1016                {
 01017                    return item;
 1018                }
 1019            }
 1020
 01021            return null;
 01022        }
 1023
 1024        /// <summary>
 1025        /// Gets the play access.
 1026        /// </summary>
 1027        /// <param name="user">The user.</param>
 1028        /// <returns>PlayAccess.</returns>
 1029        public PlayAccess GetPlayAccess(User user)
 1030        {
 111031            if (!user.HasPermission(PermissionKind.EnableMediaPlayback))
 1032            {
 01033                return PlayAccess.None;
 1034            }
 1035
 1036            // if (!user.IsParentalScheduleAllowed())
 1037            // {
 1038            //    return PlayAccess.None;
 1039            // }
 1040
 111041            return PlayAccess.Full;
 1042        }
 1043
 1044        public virtual List<MediaStream> GetMediaStreams()
 1045        {
 01046            return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
 01047            {
 01048                ItemId = Id
 01049            });
 1050        }
 1051
 1052        protected virtual bool IsActiveRecording()
 1053        {
 01054            return false;
 1055        }
 1056
 1057        public virtual List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
 1058        {
 01059            if (SourceType == SourceType.Channel)
 1060            {
 01061                var sources = ChannelManager.GetStaticMediaSources(this, CancellationToken.None)
 01062                           .ToList();
 1063
 01064                if (sources.Count > 0)
 1065                {
 01066                    return sources;
 1067                }
 1068            }
 1069
 01070            var list = GetAllItemsForMediaSources();
 01071            var result = list.Select(i => GetVersionInfo(enablePathSubstitution, i.Item, i.MediaSourceType)).ToList();
 1072
 01073            if (IsActiveRecording())
 1074            {
 01075                foreach (var mediaSource in result)
 1076                {
 01077                    mediaSource.Type = MediaSourceType.Placeholder;
 1078                }
 1079            }
 1080
 01081            return result.OrderBy(i =>
 01082            {
 01083                if (i.VideoType == VideoType.VideoFile)
 01084                {
 01085                    return 0;
 01086                }
 01087
 01088                return 1;
 01089            }).ThenBy(i => i.Video3DFormat.HasValue ? 1 : 0)
 01090            .ThenByDescending(i => i, new MediaSourceWidthComparator())
 01091            .ToList();
 1092        }
 1093
 1094        protected virtual IEnumerable<(BaseItem Item, MediaSourceType MediaSourceType)> GetAllItemsForMediaSources()
 1095        {
 01096            return Enumerable.Empty<(BaseItem, MediaSourceType)>();
 1097        }
 1098
 1099        private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type)
 1100        {
 01101            ArgumentNullException.ThrowIfNull(item);
 1102
 01103            var protocol = item.PathProtocol;
 1104
 01105            var info = new MediaSourceInfo
 01106            {
 01107                Id = item.Id.ToString("N", CultureInfo.InvariantCulture),
 01108                Protocol = protocol ?? MediaProtocol.File,
 01109                MediaStreams = MediaSourceManager.GetMediaStreams(item.Id),
 01110                MediaAttachments = MediaSourceManager.GetMediaAttachments(item.Id),
 01111                Name = GetMediaSourceName(item),
 01112                Path = enablePathSubstitution ? GetMappedPath(item, item.Path, protocol) : item.Path,
 01113                RunTimeTicks = item.RunTimeTicks,
 01114                Container = item.Container,
 01115                Size = item.Size,
 01116                Type = type,
 01117                HasSegments = MediaSegmentManager.IsTypeSupported(item)
 01118                    && (protocol is null or MediaProtocol.File)
 01119                    && MediaSegmentManager.HasSegments(item.Id)
 01120            };
 1121
 01122            if (string.IsNullOrEmpty(info.Path))
 1123            {
 01124                info.Type = MediaSourceType.Placeholder;
 1125            }
 1126
 01127            if (info.Protocol == MediaProtocol.File)
 1128            {
 01129                info.ETag = item.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N", Cultur
 1130            }
 1131
 01132            var video = item as Video;
 01133            if (video is not null)
 1134            {
 01135                info.IsoType = video.IsoType;
 01136                info.VideoType = video.VideoType;
 01137                info.Video3DFormat = video.Video3DFormat;
 01138                info.Timestamp = video.Timestamp;
 1139
 01140                if (video.IsShortcut)
 1141                {
 01142                    info.IsRemote = true;
 01143                    info.Path = video.ShortcutPath;
 01144                    info.Protocol = MediaSourceManager.GetPathProtocol(info.Path);
 1145                }
 1146
 01147                if (string.IsNullOrEmpty(info.Container))
 1148                {
 01149                    if (video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Iso)
 1150                    {
 01151                        if (protocol.HasValue && protocol.Value == MediaProtocol.File)
 1152                        {
 01153                            info.Container = System.IO.Path.GetExtension(item.Path).TrimStart('.');
 1154                        }
 1155                    }
 1156                }
 1157            }
 1158
 01159            if (string.IsNullOrEmpty(info.Container))
 1160            {
 01161                if (protocol.HasValue && protocol.Value == MediaProtocol.File)
 1162                {
 01163                    info.Container = System.IO.Path.GetExtension(item.Path).TrimStart('.');
 1164                }
 1165            }
 1166
 01167            if (info.SupportsDirectStream && !string.IsNullOrEmpty(info.Path))
 1168            {
 01169                info.SupportsDirectStream = MediaSourceManager.SupportsDirectStream(info.Path, info.Protocol);
 1170            }
 1171
 01172            if (video is not null && video.VideoType != VideoType.VideoFile)
 1173            {
 01174                info.SupportsDirectStream = false;
 1175            }
 1176
 01177            info.Bitrate = item.TotalBitrate;
 01178            info.InferTotalBitrate();
 1179
 01180            return info;
 1181        }
 1182
 1183        internal string GetMediaSourceName(BaseItem item)
 1184        {
 41185            var terms = new List<string>();
 1186
 41187            var path = item.Path;
 41188            if (item.IsFileProtocol && !string.IsNullOrEmpty(path))
 1189            {
 41190                var displayName = System.IO.Path.GetFileNameWithoutExtension(path);
 41191                if (HasLocalAlternateVersions)
 1192                {
 41193                    var containingFolderName = System.IO.Path.GetFileName(ContainingFolderPath);
 41194                    if (displayName.Length > containingFolderName.Length && displayName.StartsWith(containingFolderName,
 1195                    {
 21196                        var name = displayName.AsSpan(containingFolderName.Length).TrimStart([' ', '-']);
 21197                        if (!name.IsWhiteSpace())
 1198                        {
 21199                            terms.Add(name.ToString());
 1200                        }
 1201                    }
 1202                }
 1203
 41204                if (terms.Count == 0)
 1205                {
 21206                    terms.Add(displayName);
 1207                }
 1208            }
 1209
 41210            if (terms.Count == 0)
 1211            {
 01212                terms.Add(item.Name);
 1213            }
 1214
 41215            if (item is Video video)
 1216            {
 41217                if (video.Video3DFormat.HasValue)
 1218                {
 01219                    terms.Add("3D");
 1220                }
 1221
 41222                if (video.VideoType == VideoType.BluRay)
 1223                {
 01224                    terms.Add("Bluray");
 1225                }
 41226                else if (video.VideoType == VideoType.Dvd)
 1227                {
 01228                    terms.Add("DVD");
 1229                }
 41230                else if (video.VideoType == VideoType.Iso)
 1231                {
 01232                    if (video.IsoType.HasValue)
 1233                    {
 01234                        if (video.IsoType.Value == IsoType.BluRay)
 1235                        {
 01236                            terms.Add("Bluray");
 1237                        }
 01238                        else if (video.IsoType.Value == IsoType.Dvd)
 1239                        {
 01240                            terms.Add("DVD");
 1241                        }
 1242                    }
 1243                    else
 1244                    {
 01245                        terms.Add("ISO");
 1246                    }
 1247                }
 1248            }
 1249
 41250            return string.Join('/', terms);
 1251        }
 1252
 1253        public Task RefreshMetadata(CancellationToken cancellationToken)
 1254        {
 441255            return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(FileSystem)), cancellationToken);
 1256        }
 1257
 1258        /// <summary>
 1259        /// Overrides the base implementation to refresh metadata for local trailers.
 1260        /// </summary>
 1261        /// <param name="options">The options.</param>
 1262        /// <param name="cancellationToken">The cancellation token.</param>
 1263        /// <returns>true if a provider reports we changed.</returns>
 1264        public async Task<ItemUpdateType> RefreshMetadata(MetadataRefreshOptions options, CancellationToken cancellation
 1265        {
 1266            var requiresSave = false;
 1267
 1268            if (SupportsOwnedItems)
 1269            {
 1270                try
 1271                {
 1272                    if (IsFileProtocol)
 1273                    {
 1274                        requiresSave = await RefreshedOwnedItems(options, GetFileSystemChildren(options.DirectoryService
 1275                    }
 1276
 1277                    await LibraryManager.UpdateImagesAsync(this).ConfigureAwait(false); // ensure all image properties i
 1278                }
 1279                catch (Exception ex)
 1280                {
 1281                    Logger.LogError(ex, "Error refreshing owned items for {Path}", Path ?? Name);
 1282                }
 1283            }
 1284
 1285            var refreshOptions = requiresSave
 1286                ? new MetadataRefreshOptions(options)
 1287                {
 1288                    ForceSave = true
 1289                }
 1290                : options;
 1291
 1292            return await ProviderManager.RefreshSingleItem(this, refreshOptions, cancellationToken).ConfigureAwait(false
 1293        }
 1294
 1295        protected bool IsVisibleStandaloneInternal(User user, bool checkFolders)
 1296        {
 01297            if (!IsVisible(user))
 1298            {
 01299                return false;
 1300            }
 1301
 01302            if (GetParents().Any(i => !i.IsVisible(user)))
 1303            {
 01304                return false;
 1305            }
 1306
 01307            if (checkFolders)
 1308            {
 01309                var topParent = GetParents().LastOrDefault() ?? this;
 1310
 01311                if (string.IsNullOrEmpty(topParent.Path))
 1312                {
 01313                    return true;
 1314                }
 1315
 01316                var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList();
 1317
 01318                if (itemCollectionFolders.Count > 0)
 1319                {
 01320                    var userCollectionFolders = LibraryManager.GetUserRootFolder().GetChildren(user, true).Select(i => i
 01321                    if (!itemCollectionFolders.Any(userCollectionFolders.Contains))
 1322                    {
 01323                        return false;
 1324                    }
 1325                }
 1326            }
 1327
 01328            return true;
 1329        }
 1330
 1331        public void SetParent(Folder parent)
 1332        {
 71333            ParentId = parent is null ? Guid.Empty : parent.Id;
 71334        }
 1335
 1336        /// <summary>
 1337        /// Refreshes owned items such as trailers, theme videos, special features, etc.
 1338        /// Returns true or false indicating if changes were found.
 1339        /// </summary>
 1340        /// <param name="options">The metadata refresh options.</param>
 1341        /// <param name="fileSystemChildren">The list of filesystem children.</param>
 1342        /// <param name="cancellationToken">The cancellation token.</param>
 1343        /// <returns><c>true</c> if any items have changed, else <c>false</c>.</returns>
 1344        protected virtual async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, IReadOnlyList<FileSystemM
 1345        {
 1346            if (!IsFileProtocol || !SupportsOwnedItems || IsInMixedFolder || this is ICollectionFolder or UserRootFolder
 1347            {
 1348                return false;
 1349            }
 1350
 1351            return await RefreshExtras(this, options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
 1352        }
 1353
 1354        protected virtual FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService)
 1355        {
 421356            var path = ContainingFolderPath;
 1357
 421358            return directoryService.GetFileSystemEntries(path);
 1359        }
 1360
 1361        private async Task<bool> RefreshExtras(BaseItem item, MetadataRefreshOptions options, IReadOnlyList<FileSystemMe
 1362        {
 1363            var extras = LibraryManager.FindExtras(item, fileSystemChildren, options.DirectoryService).ToArray();
 1364            var newExtraIds = Array.ConvertAll(extras, x => x.Id);
 1365            var extrasChanged = !item.ExtraIds.SequenceEqual(newExtraIds);
 1366
 1367            if (!extrasChanged && !options.ReplaceAllMetadata && options.MetadataRefreshMode != MetadataRefreshMode.Full
 1368            {
 1369                return false;
 1370            }
 1371
 1372            var ownerId = item.Id;
 1373
 1374            var tasks = extras.Select(i =>
 1375            {
 1376                var subOptions = new MetadataRefreshOptions(options);
 1377                if (!i.OwnerId.Equals(ownerId) || !i.ParentId.IsEmpty())
 1378                {
 1379                    i.OwnerId = ownerId;
 1380                    i.ParentId = Guid.Empty;
 1381                    subOptions.ForceSave = true;
 1382                }
 1383
 1384                return RefreshMetadataForOwnedItem(i, true, subOptions, cancellationToken);
 1385            });
 1386
 1387            await Task.WhenAll(tasks).ConfigureAwait(false);
 1388
 1389            item.ExtraIds = newExtraIds;
 1390
 1391            return true;
 1392        }
 1393
 1394        public string GetPresentationUniqueKey()
 1395        {
 01396            return PresentationUniqueKey ?? CreatePresentationUniqueKey();
 1397        }
 1398
 1399        public virtual bool RequiresRefresh()
 1400        {
 461401            return false;
 1402        }
 1403
 1404        public virtual List<string> GetUserDataKeys()
 1405        {
 731406            var list = new List<string>();
 1407
 731408            if (SourceType == SourceType.Channel)
 1409            {
 01410                if (!string.IsNullOrEmpty(ExternalId))
 1411                {
 01412                    list.Add(ExternalId);
 1413                }
 1414            }
 1415
 731416            list.Add(Id.ToString());
 731417            return list;
 1418        }
 1419
 1420        internal virtual ItemUpdateType UpdateFromResolvedItem(BaseItem newItem)
 1421        {
 11422            var updateType = ItemUpdateType.None;
 1423
 11424            if (IsInMixedFolder != newItem.IsInMixedFolder)
 1425            {
 01426                IsInMixedFolder = newItem.IsInMixedFolder;
 01427                updateType |= ItemUpdateType.MetadataImport;
 1428            }
 1429
 11430            return updateType;
 1431        }
 1432
 1433        public void AfterMetadataRefresh()
 1434        {
 461435            _sortName = null;
 461436        }
 1437
 1438        /// <summary>
 1439        /// Gets the preferred metadata language.
 1440        /// </summary>
 1441        /// <returns>System.String.</returns>
 1442        public string GetPreferredMetadataLanguage()
 1443        {
 461444            string lang = PreferredMetadataLanguage;
 1445
 461446            if (string.IsNullOrEmpty(lang))
 1447            {
 461448                lang = GetParents()
 461449                    .Select(i => i.PreferredMetadataLanguage)
 461450                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1451            }
 1452
 461453            if (string.IsNullOrEmpty(lang))
 1454            {
 461455                lang = LibraryManager.GetCollectionFolders(this)
 461456                    .Select(i => i.PreferredMetadataLanguage)
 461457                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1458            }
 1459
 461460            if (string.IsNullOrEmpty(lang))
 1461            {
 461462                lang = LibraryManager.GetLibraryOptions(this).PreferredMetadataLanguage;
 1463            }
 1464
 461465            if (string.IsNullOrEmpty(lang))
 1466            {
 461467                lang = ConfigurationManager.Configuration.PreferredMetadataLanguage;
 1468            }
 1469
 461470            return lang;
 1471        }
 1472
 1473        /// <summary>
 1474        /// Gets the preferred metadata language.
 1475        /// </summary>
 1476        /// <returns>System.String.</returns>
 1477        public string GetPreferredMetadataCountryCode()
 1478        {
 461479            string lang = PreferredMetadataCountryCode;
 1480
 461481            if (string.IsNullOrEmpty(lang))
 1482            {
 461483                lang = GetParents()
 461484                    .Select(i => i.PreferredMetadataCountryCode)
 461485                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1486            }
 1487
 461488            if (string.IsNullOrEmpty(lang))
 1489            {
 461490                lang = LibraryManager.GetCollectionFolders(this)
 461491                    .Select(i => i.PreferredMetadataCountryCode)
 461492                    .FirstOrDefault(i => !string.IsNullOrEmpty(i));
 1493            }
 1494
 461495            if (string.IsNullOrEmpty(lang))
 1496            {
 461497                lang = LibraryManager.GetLibraryOptions(this).MetadataCountryCode;
 1498            }
 1499
 461500            if (string.IsNullOrEmpty(lang))
 1501            {
 461502                lang = ConfigurationManager.Configuration.MetadataCountryCode;
 1503            }
 1504
 461505            return lang;
 1506        }
 1507
 1508        public virtual bool IsSaveLocalMetadataEnabled()
 1509        {
 841510            if (SourceType == SourceType.Channel)
 1511            {
 01512                return false;
 1513            }
 1514
 841515            var libraryOptions = LibraryManager.GetLibraryOptions(this);
 1516
 841517            return libraryOptions.SaveLocalMetadata;
 1518        }
 1519
 1520        /// <summary>
 1521        /// Determines if a given user has access to this item.
 1522        /// </summary>
 1523        /// <param name="user">The user.</param>
 1524        /// <returns><c>true</c> if [is parental allowed] [the specified user]; otherwise, <c>false</c>.</returns>
 1525        /// <exception cref="ArgumentNullException">If user is null.</exception>
 1526        public bool IsParentalAllowed(User user)
 1527        {
 181528            ArgumentNullException.ThrowIfNull(user);
 1529
 181530            if (!IsVisibleViaTags(user))
 1531            {
 01532                return false;
 1533            }
 1534
 181535            var maxAllowedRating = user.MaxParentalAgeRating;
 181536            var rating = CustomRatingForComparison;
 1537
 181538            if (string.IsNullOrEmpty(rating))
 1539            {
 181540                rating = OfficialRatingForComparison;
 1541            }
 1542
 181543            if (string.IsNullOrEmpty(rating))
 1544            {
 181545                Logger.LogDebug("{0} has no parental rating set.", Name);
 181546                return !GetBlockUnratedValue(user);
 1547            }
 1548
 01549            var value = LocalizationManager.GetRatingLevel(rating);
 1550
 1551            // Could not determine rating level
 01552            if (!value.HasValue)
 1553            {
 01554                var isAllowed = !GetBlockUnratedValue(user);
 1555
 01556                if (!isAllowed)
 1557                {
 01558                    Logger.LogDebug("{0} has an unrecognized parental rating of {1}.", Name, rating);
 1559                }
 1560
 01561                return isAllowed;
 1562            }
 1563
 01564            return !maxAllowedRating.HasValue || value.Value <= maxAllowedRating.Value;
 1565        }
 1566
 1567        public int? GetInheritedParentalRatingValue()
 1568        {
 461569            var rating = CustomRatingForComparison;
 1570
 461571            if (string.IsNullOrEmpty(rating))
 1572            {
 461573                rating = OfficialRatingForComparison;
 1574            }
 1575
 461576            if (string.IsNullOrEmpty(rating))
 1577            {
 461578                return null;
 1579            }
 1580
 01581            return LocalizationManager.GetRatingLevel(rating);
 1582        }
 1583
 1584        public List<string> GetInheritedTags()
 1585        {
 771586            var list = new List<string>();
 771587            list.AddRange(Tags);
 1588
 1941589            foreach (var parent in GetParents())
 1590            {
 201591                list.AddRange(parent.Tags);
 1592            }
 1593
 1541594            foreach (var folder in LibraryManager.GetCollectionFolders(this))
 1595            {
 01596                list.AddRange(folder.Tags);
 1597            }
 1598
 771599            return list.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
 1600        }
 1601
 1602        private bool IsVisibleViaTags(User user)
 1603        {
 181604            var allTags = GetInheritedTags();
 181605            if (user.GetPreference(PreferenceKind.BlockedTags).Any(i => allTags.Contains(i, StringComparison.OrdinalIgno
 1606            {
 01607                return false;
 1608            }
 1609
 181610            var parent = GetParents().FirstOrDefault() ?? this;
 181611            if (parent is UserRootFolder or AggregateFolder)
 1612            {
 181613                return true;
 1614            }
 1615
 01616            var allowedTagsPreference = user.GetPreference(PreferenceKind.AllowedTags);
 01617            if (allowedTagsPreference.Length != 0 && !allowedTagsPreference.Any(i => allTags.Contains(i, StringCompariso
 1618            {
 01619                return false;
 1620            }
 1621
 01622            return true;
 1623        }
 1624
 1625        public virtual UnratedItem GetBlockUnratedType()
 1626        {
 591627            if (SourceType == SourceType.Channel)
 1628            {
 01629                return UnratedItem.ChannelContent;
 1630            }
 1631
 591632            return UnratedItem.Other;
 1633        }
 1634
 1635        /// <summary>
 1636        /// Gets a bool indicating if access to the unrated item is blocked or not.
 1637        /// </summary>
 1638        /// <param name="user">The configuration.</param>
 1639        /// <returns><c>true</c> if blocked, <c>false</c> otherwise.</returns>
 1640        protected virtual bool GetBlockUnratedValue(User user)
 1641        {
 1642            // Don't block plain folders that are unrated. Let the media underneath get blocked
 1643            // Special folders like series and albums will override this method.
 181644            if (IsFolder || this is IItemByName)
 1645            {
 181646                return false;
 1647            }
 1648
 01649            return user.GetPreferenceValues<UnratedItem>(PreferenceKind.BlockUnratedItems).Contains(GetBlockUnratedType(
 1650        }
 1651
 1652        /// <summary>
 1653        /// Determines if this folder should be visible to a given user.
 1654        /// Default is just parental allowed. Can be overridden for more functionality.
 1655        /// </summary>
 1656        /// <param name="user">The user.</param>
 1657        /// <returns><c>true</c> if the specified user is visible; otherwise, <c>false</c>.</returns>
 1658        /// <exception cref="ArgumentNullException"><paramref name="user" /> is <c>null</c>.</exception>
 1659        public virtual bool IsVisible(User user)
 1660        {
 181661            ArgumentNullException.ThrowIfNull(user);
 1662
 181663            return IsParentalAllowed(user);
 1664        }
 1665
 1666        public virtual bool IsVisibleStandalone(User user)
 1667        {
 01668            if (SourceType == SourceType.Channel)
 1669            {
 01670                return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
 1671            }
 1672
 01673            return IsVisibleStandaloneInternal(user, true);
 1674        }
 1675
 1676        public virtual string GetClientTypeName()
 1677        {
 741678            if (IsFolder && SourceType == SourceType.Channel && this is not Channel)
 1679            {
 01680                return "ChannelFolderItem";
 1681            }
 1682
 741683            return GetType().Name;
 1684        }
 1685
 1686        public BaseItemKind GetBaseItemKind()
 1687        {
 2611688            return _baseItemKind ??= Enum.Parse<BaseItemKind>(GetClientTypeName());
 1689        }
 1690
 1691        /// <summary>
 1692        /// Gets the linked child.
 1693        /// </summary>
 1694        /// <param name="info">The info.</param>
 1695        /// <returns>BaseItem.</returns>
 1696        protected BaseItem GetLinkedChild(LinkedChild info)
 1697        {
 1698            // First get using the cached Id
 01699            if (info.ItemId.HasValue)
 1700            {
 01701                if (info.ItemId.Value.IsEmpty())
 1702                {
 01703                    return null;
 1704                }
 1705
 01706                var itemById = LibraryManager.GetItemById(info.ItemId.Value);
 1707
 01708                if (itemById is not null)
 1709                {
 01710                    return itemById;
 1711                }
 1712            }
 1713
 01714            var item = FindLinkedChild(info);
 1715
 1716            // If still null, log
 01717            if (item is null)
 1718            {
 1719                // Don't keep searching over and over
 01720                info.ItemId = Guid.Empty;
 1721            }
 1722            else
 1723            {
 1724                // Cache the id for next time
 01725                info.ItemId = item.Id;
 1726            }
 1727
 01728            return item;
 1729        }
 1730
 1731        private BaseItem FindLinkedChild(LinkedChild info)
 1732        {
 01733            var path = info.Path;
 1734
 01735            if (!string.IsNullOrEmpty(path))
 1736            {
 01737                path = FileSystem.MakeAbsolutePath(ContainingFolderPath, path);
 1738
 01739                var itemByPath = LibraryManager.FindByPath(path, null);
 1740
 01741                if (itemByPath is null)
 1742                {
 01743                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1744                }
 1745
 01746                return itemByPath;
 1747            }
 1748
 01749            if (!string.IsNullOrEmpty(info.LibraryItemId))
 1750            {
 01751                var item = LibraryManager.GetItemById(info.LibraryItemId);
 1752
 01753                if (item is null)
 1754                {
 01755                    Logger.LogWarning("Unable to find linked item at path {0}", info.Path);
 1756                }
 1757
 01758                return item;
 1759            }
 1760
 01761            return null;
 1762        }
 1763
 1764        /// <summary>
 1765        /// Adds a studio to the item.
 1766        /// </summary>
 1767        /// <param name="name">The name.</param>
 1768        /// <exception cref="ArgumentNullException">Throws if name is null.</exception>
 1769        public void AddStudio(string name)
 1770        {
 41771            ArgumentException.ThrowIfNullOrEmpty(name);
 1772
 41773            var current = Studios;
 1774
 41775            if (!current.Contains(name, StringComparison.OrdinalIgnoreCase))
 1776            {
 41777                int curLen = current.Length;
 41778                if (curLen == 0)
 1779                {
 41780                    Studios = [name];
 1781                }
 1782                else
 1783                {
 01784                    Studios = [..current, name];
 1785                }
 1786            }
 01787        }
 1788
 1789        public void SetStudios(IEnumerable<string> names)
 1790        {
 01791            Studios = names.Distinct().ToArray();
 01792        }
 1793
 1794        /// <summary>
 1795        /// Adds a genre to the item.
 1796        /// </summary>
 1797        /// <param name="name">The name.</param>
 1798        /// <exception cref="ArgumentNullException">Throwns if name is null.</exception>
 1799        public void AddGenre(string name)
 1800        {
 131801            ArgumentException.ThrowIfNullOrEmpty(name);
 1802
 131803            var genres = Genres;
 131804            if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))
 1805            {
 131806                Genres = [..genres, name];
 1807            }
 131808        }
 1809
 1810        /// <summary>
 1811        /// Marks the played.
 1812        /// </summary>
 1813        /// <param name="user">The user.</param>
 1814        /// <param name="datePlayed">The date played.</param>
 1815        /// <param name="resetPosition">if set to <c>true</c> [reset position].</param>
 1816        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1817        public virtual void MarkPlayed(
 1818            User user,
 1819            DateTime? datePlayed,
 1820            bool resetPosition)
 1821        {
 01822            ArgumentNullException.ThrowIfNull(user);
 1823
 01824            var data = UserDataManager.GetUserData(user, this);
 1825
 01826            if (datePlayed.HasValue)
 1827            {
 1828                // Increment
 01829                data.PlayCount++;
 1830            }
 1831
 1832            // Ensure it's at least one
 01833            data.PlayCount = Math.Max(data.PlayCount, 1);
 1834
 01835            if (resetPosition)
 1836            {
 01837                data.PlaybackPositionTicks = 0;
 1838            }
 1839
 01840            data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
 01841            data.Played = true;
 1842
 01843            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01844        }
 1845
 1846        /// <summary>
 1847        /// Marks the unplayed.
 1848        /// </summary>
 1849        /// <param name="user">The user.</param>
 1850        /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
 1851        public virtual void MarkUnplayed(User user)
 1852        {
 01853            ArgumentNullException.ThrowIfNull(user);
 1854
 01855            var data = UserDataManager.GetUserData(user, this);
 1856
 1857            // I think it is okay to do this here.
 1858            // if this is only called when a user is manually forcing something to un-played
 1859            // then it probably is what we want to do...
 01860            data.PlayCount = 0;
 01861            data.PlaybackPositionTicks = 0;
 01862            data.LastPlayedDate = null;
 01863            data.Played = false;
 1864
 01865            UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
 01866        }
 1867
 1868        /// <summary>
 1869        /// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed.
 1870        /// </summary>
 1871        public virtual void ChangedExternally()
 1872        {
 01873            ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem)), RefreshPriori
 01874        }
 1875
 1876        /// <summary>
 1877        /// Gets an image.
 1878        /// </summary>
 1879        /// <param name="type">The type.</param>
 1880        /// <param name="imageIndex">Index of the image.</param>
 1881        /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
 1882        /// <exception cref="ArgumentException">Backdrops should be accessed using Item.Backdrops.</exception>
 1883        public bool HasImage(ImageType type, int imageIndex)
 1884        {
 1431885            return GetImageInfo(type, imageIndex) is not null;
 1886        }
 1887
 1888        public void SetImage(ItemImageInfo image, int index)
 1889        {
 131890            if (image.Type == ImageType.Chapter)
 1891            {
 01892                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1893            }
 1894
 131895            var existingImage = GetImageInfo(image.Type, index);
 1896
 131897            if (existingImage is null)
 1898            {
 111899                AddImage(image);
 1900            }
 1901            else
 1902            {
 21903                existingImage.Path = image.Path;
 21904                existingImage.DateModified = image.DateModified;
 21905                existingImage.Width = image.Width;
 21906                existingImage.Height = image.Height;
 21907                existingImage.BlurHash = image.BlurHash;
 1908            }
 21909        }
 1910
 1911        public void SetImagePath(ImageType type, int index, FileSystemMetadata file)
 1912        {
 461913            if (type == ImageType.Chapter)
 1914            {
 01915                throw new ArgumentException("Cannot set chapter images using SetImagePath");
 1916            }
 1917
 461918            var image = GetImageInfo(type, index);
 1919
 461920            if (image is null)
 1921            {
 451922                AddImage(GetImageInfo(file, type));
 1923            }
 1924            else
 1925            {
 11926                var imageInfo = GetImageInfo(file, type);
 1927
 11928                image.Path = file.FullName;
 11929                image.DateModified = imageInfo.DateModified;
 1930
 1931                // reset these values
 11932                image.Width = 0;
 11933                image.Height = 0;
 1934            }
 11935        }
 1936
 1937        /// <summary>
 1938        /// Deletes the image.
 1939        /// </summary>
 1940        /// <param name="type">The type.</param>
 1941        /// <param name="index">The index.</param>
 1942        /// <returns>A task.</returns>
 1943        public async Task DeleteImageAsync(ImageType type, int index)
 1944        {
 1945            var info = GetImageInfo(type, index);
 1946
 1947            if (info is null)
 1948            {
 1949                // Nothing to do
 1950                return;
 1951            }
 1952
 1953            // Remove from file system
 1954            if (info.IsLocalFile)
 1955            {
 1956                FileSystem.DeleteFile(info.Path);
 1957            }
 1958
 1959            // Remove from item
 1960            RemoveImage(info);
 1961
 1962            await UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None).ConfigureAwait(false);
 1963        }
 1964
 1965        public void RemoveImage(ItemImageInfo image)
 1966        {
 01967            RemoveImages(new[] { image });
 01968        }
 1969
 1970        public void RemoveImages(IEnumerable<ItemImageInfo> deletedImages)
 1971        {
 91972            ImageInfos = ImageInfos.Except(deletedImages).ToArray();
 91973        }
 1974
 1975        public void AddImage(ItemImageInfo image)
 1976        {
 561977            ImageInfos = [..ImageInfos, image];
 561978        }
 1979
 1980        public virtual Task UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationToken)
 581981         => LibraryManager.UpdateItemAsync(this, GetParent(), updateReason, cancellationToken);
 1982
 1983        /// <summary>
 1984        /// Validates that images within the item are still on the filesystem.
 1985        /// </summary>
 1986        /// <returns><c>true</c> if the images validate, <c>false</c> if not.</returns>
 1987        public bool ValidateImages()
 1988        {
 601989            List<ItemImageInfo> deletedImages = null;
 1501990            foreach (var imageInfo in ImageInfos)
 1991            {
 151992                if (!imageInfo.IsLocalFile)
 1993                {
 1994                    continue;
 1995                }
 1996
 151997                if (File.Exists(imageInfo.Path))
 1998                {
 1999                    continue;
 2000                }
 2001
 32002                (deletedImages ??= new List<ItemImageInfo>()).Add(imageInfo);
 2003            }
 2004
 602005            var anyImagesRemoved = deletedImages?.Count > 0;
 602006            if (anyImagesRemoved)
 2007            {
 22008                RemoveImages(deletedImages);
 2009            }
 2010
 602011            return anyImagesRemoved;
 2012        }
 2013
 2014        /// <summary>
 2015        /// Gets the image path.
 2016        /// </summary>
 2017        /// <param name="imageType">Type of the image.</param>
 2018        /// <param name="imageIndex">Index of the image.</param>
 2019        /// <returns>System.String.</returns>
 2020        /// <exception cref="ArgumentNullException">Item is null.</exception>
 2021        public string GetImagePath(ImageType imageType, int imageIndex)
 22022            => GetImageInfo(imageType, imageIndex)?.Path;
 2023
 2024        /// <summary>
 2025        /// Gets the image information.
 2026        /// </summary>
 2027        /// <param name="imageType">Type of the image.</param>
 2028        /// <param name="imageIndex">Index of the image.</param>
 2029        /// <returns>ItemImageInfo.</returns>
 2030        public ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex)
 2031        {
 3022032            if (imageType == ImageType.Chapter)
 2033            {
 02034                var chapter = ItemRepository.GetChapter(this, imageIndex);
 2035
 02036                if (chapter is null)
 2037                {
 02038                    return null;
 2039                }
 2040
 02041                var path = chapter.ImagePath;
 2042
 02043                if (string.IsNullOrEmpty(path))
 2044                {
 02045                    return null;
 2046                }
 2047
 02048                return new ItemImageInfo
 02049                {
 02050                    Path = path,
 02051                    DateModified = chapter.ImageDateModified,
 02052                    Type = imageType
 02053                };
 2054            }
 2055
 2056            // Music albums usually don't have dedicated backdrops, so return one from the artist instead
 3022057            if (GetType() == typeof(MusicAlbum) && imageType == ImageType.Backdrop)
 2058            {
 02059                var artist = FindParent<MusicArtist>();
 2060
 02061                if (artist is not null)
 2062                {
 02063                    return artist.GetImages(imageType).ElementAtOrDefault(imageIndex);
 2064                }
 2065            }
 2066
 3022067            return GetImages(imageType)
 3022068                .ElementAtOrDefault(imageIndex);
 2069        }
 2070
 2071        /// <summary>
 2072        /// Computes image index for given image or raises if no matching image found.
 2073        /// </summary>
 2074        /// <param name="image">Image to compute index for.</param>
 2075        /// <exception cref="ArgumentException">Image index cannot be computed as no matching image found.
 2076        /// </exception>
 2077        /// <returns>Image index.</returns>
 2078        public int GetImageIndex(ItemImageInfo image)
 2079        {
 02080            ArgumentNullException.ThrowIfNull(image);
 2081
 02082            if (image.Type == ImageType.Chapter)
 2083            {
 02084                var chapters = ItemRepository.GetChapters(this);
 02085                for (var i = 0; i < chapters.Count; i++)
 2086                {
 02087                    if (chapters[i].ImagePath == image.Path)
 2088                    {
 02089                        return i;
 2090                    }
 2091                }
 2092
 02093                throw new ArgumentException("No chapter index found for image path", image.Path);
 2094            }
 2095
 02096            var images = GetImages(image.Type).ToArray();
 02097            for (var i = 0; i < images.Length; i++)
 2098            {
 02099                if (images[i].Path == image.Path)
 2100                {
 02101                    return i;
 2102                }
 2103            }
 2104
 02105            throw new ArgumentException("No image index found for image path", image.Path);
 2106        }
 2107
 2108        public IEnumerable<ItemImageInfo> GetImages(ImageType imageType)
 2109        {
 2110            if (imageType == ImageType.Chapter)
 2111            {
 2112                throw new ArgumentException("No image info for chapter images");
 2113            }
 2114
 2115            // Yield return is more performant than LINQ Where on an Array
 2116            for (var i = 0; i < ImageInfos.Length; i++)
 2117            {
 2118                var imageInfo = ImageInfos[i];
 2119                if (imageInfo.Type == imageType)
 2120                {
 2121                    yield return imageInfo;
 2122                }
 2123            }
 2124        }
 2125
 2126        /// <summary>
 2127        /// Adds the images, updating metadata if they already are part of this item.
 2128        /// </summary>
 2129        /// <param name="imageType">Type of the image.</param>
 2130        /// <param name="images">The images.</param>
 2131        /// <returns><c>true</c> if images were added or updated, <c>false</c> otherwise.</returns>
 2132        /// <exception cref="ArgumentException">Cannot call AddImages with chapter images.</exception>
 2133        public bool AddImages(ImageType imageType, List<FileSystemMetadata> images)
 2134        {
 602135            if (imageType == ImageType.Chapter)
 2136            {
 02137                throw new ArgumentException("Cannot call AddImages with chapter images");
 2138            }
 2139
 602140            var existingImages = GetImages(imageType)
 602141                .ToList();
 2142
 602143            var newImageList = new List<FileSystemMetadata>();
 602144            var imageUpdated = false;
 2145
 1362146            foreach (var newImage in images)
 2147            {
 82148                if (newImage is null)
 2149                {
 02150                    throw new ArgumentException("null image found in list");
 2151                }
 2152
 82153                var existing = existingImages
 82154                    .Find(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase));
 2155
 82156                if (existing is null)
 2157                {
 42158                    newImageList.Add(newImage);
 2159                }
 2160                else
 2161                {
 42162                    if (existing.IsLocalFile)
 2163                    {
 42164                        var newDateModified = FileSystem.GetLastWriteTimeUtc(newImage);
 2165
 2166                        // If date changed then we need to reset saved image dimensions
 42167                        if (existing.DateModified != newDateModified && (existing.Width > 0 || existing.Height > 0))
 2168                        {
 22169                            existing.Width = 0;
 22170                            existing.Height = 0;
 22171                            imageUpdated = true;
 2172                        }
 2173
 42174                        existing.DateModified = newDateModified;
 2175                    }
 2176                }
 2177            }
 2178
 602179            if (newImageList.Count > 0)
 2180            {
 22181                ImageInfos = ImageInfos.Concat(newImageList.Select(i => GetImageInfo(i, imageType))).ToArray();
 2182            }
 2183
 602184            return imageUpdated || newImageList.Count > 0;
 2185        }
 2186
 2187        private ItemImageInfo GetImageInfo(FileSystemMetadata file, ImageType type)
 2188        {
 502189            return new ItemImageInfo
 502190            {
 502191                Path = file.FullName,
 502192                Type = type,
 502193                DateModified = FileSystem.GetLastWriteTimeUtc(file)
 502194            };
 2195        }
 2196
 2197        /// <summary>
 2198        /// Gets the file system path to delete when the item is to be deleted.
 2199        /// </summary>
 2200        /// <returns>The metadata for the deleted paths.</returns>
 2201        public virtual IEnumerable<FileSystemMetadata> GetDeletePaths()
 2202        {
 02203            return new[]
 02204            {
 02205                new FileSystemMetadata
 02206                {
 02207                    FullName = Path,
 02208                    IsDirectory = IsFolder
 02209                }
 02210            }.Concat(GetLocalMetadataFilesToDelete());
 2211        }
 2212
 2213        protected List<FileSystemMetadata> GetLocalMetadataFilesToDelete()
 2214        {
 02215            if (IsFolder || !IsInMixedFolder)
 2216            {
 02217                return new List<FileSystemMetadata>();
 2218            }
 2219
 02220            var filename = System.IO.Path.GetFileNameWithoutExtension(Path);
 2221
 02222            return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), _supportedExtensions, false, false)
 02223                .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison
 02224                .ToList();
 2225        }
 2226
 2227        public bool AllowsMultipleImages(ImageType type)
 2228        {
 182229            return type == ImageType.Backdrop || type == ImageType.Chapter;
 2230        }
 2231
 2232        public Task SwapImagesAsync(ImageType type, int index1, int index2)
 2233        {
 02234            if (!AllowsMultipleImages(type))
 2235            {
 02236                throw new ArgumentException("The change index operation is only applicable to backdrops and screen shots
 2237            }
 2238
 02239            var info1 = GetImageInfo(type, index1);
 02240            var info2 = GetImageInfo(type, index2);
 2241
 02242            if (info1 is null || info2 is null)
 2243            {
 2244                // Nothing to do
 02245                return Task.CompletedTask;
 2246            }
 2247
 02248            if (!info1.IsLocalFile || !info2.IsLocalFile)
 2249            {
 2250                // TODO: Not supported  yet
 02251                return Task.CompletedTask;
 2252            }
 2253
 02254            var path1 = info1.Path;
 02255            var path2 = info2.Path;
 2256
 02257            FileSystem.SwapFiles(path1, path2);
 2258
 2259            // Refresh these values
 02260            info1.DateModified = FileSystem.GetLastWriteTimeUtc(info1.Path);
 02261            info2.DateModified = FileSystem.GetLastWriteTimeUtc(info2.Path);
 2262
 02263            info1.Width = 0;
 02264            info1.Height = 0;
 02265            info2.Width = 0;
 02266            info2.Height = 0;
 2267
 02268            return UpdateToRepositoryAsync(ItemUpdateType.ImageUpdate, CancellationToken.None);
 2269        }
 2270
 2271        public virtual bool IsPlayed(User user)
 2272        {
 02273            var userdata = UserDataManager.GetUserData(user, this);
 2274
 02275            return userdata is not null && userdata.Played;
 2276        }
 2277
 2278        public bool IsFavoriteOrLiked(User user)
 2279        {
 02280            var userdata = UserDataManager.GetUserData(user, this);
 2281
 02282            return userdata is not null && (userdata.IsFavorite || (userdata.Likes ?? false));
 2283        }
 2284
 2285        public virtual bool IsUnplayed(User user)
 2286        {
 02287            ArgumentNullException.ThrowIfNull(user);
 2288
 02289            var userdata = UserDataManager.GetUserData(user, this);
 2290
 02291            return userdata is null || !userdata.Played;
 2292        }
 2293
 2294        ItemLookupInfo IHasLookupInfo<ItemLookupInfo>.GetLookupInfo()
 2295        {
 462296            return GetItemLookupInfo<ItemLookupInfo>();
 2297        }
 2298
 2299        protected T GetItemLookupInfo<T>()
 2300            where T : ItemLookupInfo, new()
 2301        {
 462302            return new T
 462303            {
 462304                Path = Path,
 462305                MetadataCountryCode = GetPreferredMetadataCountryCode(),
 462306                MetadataLanguage = GetPreferredMetadataLanguage(),
 462307                Name = GetNameForMetadataLookup(),
 462308                OriginalTitle = OriginalTitle,
 462309                ProviderIds = ProviderIds,
 462310                IndexNumber = IndexNumber,
 462311                ParentIndexNumber = ParentIndexNumber,
 462312                Year = ProductionYear,
 462313                PremiereDate = PremiereDate
 462314            };
 2315        }
 2316
 2317        protected virtual string GetNameForMetadataLookup()
 2318        {
 462319            return Name;
 2320        }
 2321
 2322        /// <summary>
 2323        /// This is called before any metadata refresh and returns true if changes were made.
 2324        /// </summary>
 2325        /// <param name="replaceAllMetadata">Whether to replace all metadata.</param>
 2326        /// <returns>true if the item has change, else false.</returns>
 2327        public virtual bool BeforeMetadataRefresh(bool replaceAllMetadata)
 2328        {
 462329            _sortName = null;
 2330
 462331            var hasChanges = false;
 2332
 462333            if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path))
 2334            {
 02335                Name = System.IO.Path.GetFileNameWithoutExtension(Path);
 02336                hasChanges = true;
 2337            }
 2338
 462339            return hasChanges;
 2340        }
 2341
 2342        protected static string GetMappedPath(BaseItem item, string path, MediaProtocol? protocol)
 2343        {
 02344            if (protocol == MediaProtocol.File)
 2345            {
 02346                return LibraryManager.GetPathAfterNetworkSubstitution(path, item);
 2347            }
 2348
 02349            return path;
 2350        }
 2351
 2352        public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User 
 2353        {
 02354            if (RunTimeTicks.HasValue)
 2355            {
 02356                double pct = RunTimeTicks.Value;
 2357
 02358                if (pct > 0)
 2359                {
 02360                    pct = userData.PlaybackPositionTicks / pct;
 2361
 02362                    if (pct > 0)
 2363                    {
 02364                        dto.PlayedPercentage = 100 * pct;
 2365                    }
 2366                }
 2367            }
 02368        }
 2369
 2370        protected Task RefreshMetadataForOwnedItem(BaseItem ownedItem, bool copyTitleMetadata, MetadataRefreshOptions op
 2371        {
 02372            var newOptions = new MetadataRefreshOptions(options)
 02373            {
 02374                SearchResult = null
 02375            };
 2376
 02377            var item = this;
 2378
 02379            if (copyTitleMetadata)
 2380            {
 2381                // Take some data from the main item, for querying purposes
 02382                if (!item.Genres.SequenceEqual(ownedItem.Genres, StringComparer.Ordinal))
 2383                {
 02384                    newOptions.ForceSave = true;
 02385                    ownedItem.Genres = item.Genres;
 2386                }
 2387
 02388                if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal))
 2389                {
 02390                    newOptions.ForceSave = true;
 02391                    ownedItem.Studios = item.Studios;
 2392                }
 2393
 02394                if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal))
 2395                {
 02396                    newOptions.ForceSave = true;
 02397                    ownedItem.ProductionLocations = item.ProductionLocations;
 2398                }
 2399
 02400                if (item.CommunityRating != ownedItem.CommunityRating)
 2401                {
 02402                    ownedItem.CommunityRating = item.CommunityRating;
 02403                    newOptions.ForceSave = true;
 2404                }
 2405
 02406                if (item.CriticRating != ownedItem.CriticRating)
 2407                {
 02408                    ownedItem.CriticRating = item.CriticRating;
 02409                    newOptions.ForceSave = true;
 2410                }
 2411
 02412                if (!string.Equals(item.Overview, ownedItem.Overview, StringComparison.Ordinal))
 2413                {
 02414                    ownedItem.Overview = item.Overview;
 02415                    newOptions.ForceSave = true;
 2416                }
 2417
 02418                if (!string.Equals(item.OfficialRating, ownedItem.OfficialRating, StringComparison.Ordinal))
 2419                {
 02420                    ownedItem.OfficialRating = item.OfficialRating;
 02421                    newOptions.ForceSave = true;
 2422                }
 2423
 02424                if (!string.Equals(item.CustomRating, ownedItem.CustomRating, StringComparison.Ordinal))
 2425                {
 02426                    ownedItem.CustomRating = item.CustomRating;
 02427                    newOptions.ForceSave = true;
 2428                }
 2429            }
 2430
 02431            return ownedItem.RefreshMetadata(newOptions, cancellationToken);
 2432        }
 2433
 2434        protected Task RefreshMetadataForOwnedVideo(MetadataRefreshOptions options, bool copyTitleMetadata, string path,
 2435        {
 02436            var newOptions = new MetadataRefreshOptions(options)
 02437            {
 02438                SearchResult = null
 02439            };
 2440
 02441            var id = LibraryManager.GetNewItemId(path, typeof(Video));
 2442
 2443            // Try to retrieve it from the db. If we don't find it, use the resolved version
 02444            var video = LibraryManager.GetItemById(id) as Video;
 2445
 02446            if (video is null)
 2447            {
 02448                video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video;
 2449
 02450                newOptions.ForceSave = true;
 2451            }
 2452
 02453            if (video is null)
 2454            {
 02455                return Task.FromResult(true);
 2456            }
 2457
 02458            if (video.OwnerId.IsEmpty())
 2459            {
 02460                video.OwnerId = this.Id;
 2461            }
 2462
 02463            return RefreshMetadataForOwnedItem(video, copyTitleMetadata, newOptions, cancellationToken);
 2464        }
 2465
 2466        public string GetEtag(User user)
 2467        {
 112468            var list = GetEtagValues(user);
 2469
 112470            return string.Join('|', list).GetMD5().ToString("N", CultureInfo.InvariantCulture);
 2471        }
 2472
 2473        protected virtual List<string> GetEtagValues(User user)
 2474        {
 112475            return new List<string>
 112476            {
 112477                DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture)
 112478            };
 2479        }
 2480
 2481        public virtual IEnumerable<Guid> GetAncestorIds()
 2482        {
 592483            return GetParents().Select(i => i.Id).Concat(LibraryManager.GetCollectionFolders(this).Select(i => i.Id));
 2484        }
 2485
 2486        public BaseItem GetTopParent()
 2487        {
 592488            if (IsTopParent)
 2489            {
 222490                return this;
 2491            }
 2492
 372493            return GetParents().FirstOrDefault(parent => parent.IsTopParent);
 2494        }
 2495
 2496        public virtual IEnumerable<Guid> GetIdsForAncestorQuery()
 2497        {
 262498            return new[] { Id };
 2499        }
 2500
 2501        public virtual double? GetRefreshProgress()
 2502        {
 02503            return null;
 2504        }
 2505
 2506        public virtual ItemUpdateType OnMetadataChanged()
 2507        {
 462508            var updateType = ItemUpdateType.None;
 2509
 462510            var item = this;
 2511
 462512            var inheritedParentalRatingValue = item.GetInheritedParentalRatingValue() ?? null;
 462513            if (inheritedParentalRatingValue != item.InheritedParentalRatingValue)
 2514            {
 02515                item.InheritedParentalRatingValue = inheritedParentalRatingValue;
 02516                updateType |= ItemUpdateType.MetadataImport;
 2517            }
 2518
 462519            return updateType;
 2520        }
 2521
 2522        /// <summary>
 2523        /// Updates the official rating based on content and returns true or false indicating if it changed.
 2524        /// </summary>
 2525        /// <param name="children">Media children.</param>
 2526        /// <returns><c>true</c> if the rating was updated; otherwise <c>false</c>.</returns>
 2527        public bool UpdateRatingToItems(IList<BaseItem> children)
 2528        {
 02529            var currentOfficialRating = OfficialRating;
 2530
 2531            // Gather all possible ratings
 02532            var ratings = children
 02533                .Select(i => i.OfficialRating)
 02534                .Where(i => !string.IsNullOrEmpty(i))
 02535                .Distinct(StringComparer.OrdinalIgnoreCase)
 02536                .Select(rating => (rating, LocalizationManager.GetRatingLevel(rating)))
 02537                .OrderBy(i => i.Item2 ?? 1000)
 02538                .Select(i => i.rating);
 2539
 02540            OfficialRating = ratings.FirstOrDefault() ?? currentOfficialRating;
 2541
 02542            return !string.Equals(
 02543                currentOfficialRating ?? string.Empty,
 02544                OfficialRating ?? string.Empty,
 02545                StringComparison.OrdinalIgnoreCase);
 2546        }
 2547
 2548        public IReadOnlyList<BaseItem> GetThemeSongs(User user = null)
 2549        {
 02550            return GetThemeSongs(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2551        }
 2552
 2553        public IReadOnlyList<BaseItem> GetThemeSongs(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> or
 2554        {
 02555            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeSong), user, 
 2556        }
 2557
 2558        public IReadOnlyList<BaseItem> GetThemeVideos(User user = null)
 2559        {
 02560            return GetThemeVideos(user, Array.Empty<(ItemSortBy, SortOrder)>());
 2561        }
 2562
 2563        public IReadOnlyList<BaseItem> GetThemeVideos(User user, IEnumerable<(ItemSortBy SortBy, SortOrder SortOrder)> o
 2564        {
 02565            return LibraryManager.Sort(GetExtras().Where(e => e.ExtraType == Model.Entities.ExtraType.ThemeVideo), user,
 2566        }
 2567
 2568        /// <summary>
 2569        /// Get all extras associated with this item, sorted by <see cref="SortName"/>.
 2570        /// </summary>
 2571        /// <returns>An enumerable containing the items.</returns>
 2572        public IEnumerable<BaseItem> GetExtras()
 2573        {
 132574            return ExtraIds
 132575                .Select(LibraryManager.GetItemById)
 132576                .Where(i => i is not null)
 132577                .OrderBy(i => i.SortName);
 2578        }
 2579
 2580        /// <summary>
 2581        /// Get all extras with specific types that are associated with this item.
 2582        /// </summary>
 2583        /// <param name="extraTypes">The types of extras to retrieve.</param>
 2584        /// <returns>An enumerable containing the extras.</returns>
 2585        public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
 2586        {
 02587            return ExtraIds
 02588                .Select(LibraryManager.GetItemById)
 02589                .Where(i => i is not null)
 02590                .Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value))
 02591                .OrderBy(i => i.SortName);
 2592        }
 2593
 2594        public virtual long GetRunTimeTicksForPlayState()
 2595        {
 02596            return RunTimeTicks ?? 0;
 2597        }
 2598
 2599        /// <inheritdoc />
 2600        public override bool Equals(object obj)
 2601        {
 02602            return obj is BaseItem baseItem && this.Equals(baseItem);
 2603        }
 2604
 2605        /// <inheritdoc />
 12606        public bool Equals(BaseItem other) => other is not null && other.Id.Equals(Id);
 2607
 2608        /// <inheritdoc />
 572609        public override int GetHashCode() => HashCode.Combine(Id);
 2610    }
 2611}

Methods/Properties

.cctor()
.ctor()
get_SupportsAddingToPlaylist()
get_AlwaysScanInternalMetadataPath()
get_SupportsPlayedStatus()
get_SupportsPositionTicksResume()
get_SupportsRemoteImageDownloading()
get_Name()
set_Name(System.String)
get_IsUnaired()
get_IsThemeMedia()
get_DisplayPreferencesId()
get_SourceType()
get_ContainingFolderPath()
get_IsHidden()
get_LocationType()
get_PathProtocol()
get_IsFileProtocol()
get_HasPathProtocol()
get_SupportsLocalMetadata()
get_FileNameWithoutExtension()
get_EnableAlphaNumericSorting()
get_IsHD()
get_PrimaryImagePath()
get_MediaType()
get_PhysicalLocations()
get_EnableMediaSourceDisplay()
get_ForcedSortName()
set_ForcedSortName(System.String)
get_SortName()
set_SortName(System.String)
get_DisplayParentId()
get_DisplayParent()
get_HasLocalAlternateVersions()
get_OfficialRatingForComparison()
get_CustomRatingForComparison()
get_LatestItemsIndexContainer()
get_EnableRememberingTrackSelections()
get_IsTopParent()
get_SupportsAncestors()
get_SupportsOwnedItems()
get_SupportsPeople()
get_SupportsThemeMedia()
get_SupportsInheritedParentImages()
get_IsFolder()
get_IsDisplayedAsFolder()
GetDefaultPrimaryImageAspectRatio()
CreatePresentationUniqueKey()
CanDelete()
IsAuthorizedToDelete(Jellyfin.Data.Entities.User,System.Collections.Generic.List`1<MediaBrowser.Controller.Entities.Folder>)
GetOwner()
CanDelete(Jellyfin.Data.Entities.User,System.Collections.Generic.List`1<MediaBrowser.Controller.Entities.Folder>)
CanDelete(Jellyfin.Data.Entities.User)
CanDownload()
IsAuthorizedToDownload(Jellyfin.Data.Entities.User)
CanDownload(Jellyfin.Data.Entities.User)
ToString()
GetInternalMetadataPath()
GetInternalMetadataPath(System.String)
CreateSortName()
ModifySortChunks(System.ReadOnlySpan`1<System.Char>)
GetParent()
FindParent()
GetPlayAccess(Jellyfin.Data.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.Data.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.Data.Entities.User)
GetInheritedParentalRatingValue()
GetInheritedTags()
IsVisibleViaTags(Jellyfin.Data.Entities.User)
GetBlockUnratedType()
GetBlockUnratedValue(Jellyfin.Data.Entities.User)
IsVisible(Jellyfin.Data.Entities.User)
IsVisibleStandalone(Jellyfin.Data.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.Data.Entities.User,System.Nullable`1<System.DateTime>,System.Boolean)
MarkUnplayed(Jellyfin.Data.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)
UpdateToRepositoryAsync(MediaBrowser.Controller.Library.ItemUpdateType,System.Threading.CancellationToken)
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.Data.Entities.User)
IsFavoriteOrLiked(Jellyfin.Data.Entities.User)
IsUnplayed(Jellyfin.Data.Entities.User)
MediaBrowser.Controller.Providers.IHasLookupInfo<MediaBrowser.Controller.Providers.ItemLookupInfo>.GetLookupInfo()
GetItemLookupInfo()
GetNameForMetadataLookup()
BeforeMetadataRefresh(System.Boolean)
GetMappedPath(MediaBrowser.Controller.Entities.BaseItem,System.String,System.Nullable`1<MediaBrowser.Model.MediaInfo.MediaProtocol>)
FillUserDataDtoValues(MediaBrowser.Model.Dto.UserItemDataDto,MediaBrowser.Controller.Entities.UserItemData,MediaBrowser.Model.Dto.BaseItemDto,Jellyfin.Data.Entities.User,MediaBrowser.Controller.Dto.DtoOptions)
RefreshMetadataForOwnedItem(MediaBrowser.Controller.Entities.BaseItem,System.Boolean,MediaBrowser.Controller.Providers.MetadataRefreshOptions,System.Threading.CancellationToken)
RefreshMetadataForOwnedVideo(MediaBrowser.Controller.Providers.MetadataRefreshOptions,System.Boolean,System.String,System.Threading.CancellationToken)
GetEtag(Jellyfin.Data.Entities.User)
GetEtagValues(Jellyfin.Data.Entities.User)
GetAncestorIds()
GetTopParent()
GetIdsForAncestorQuery()
GetRefreshProgress()
OnMetadataChanged()
UpdateRatingToItems(System.Collections.Generic.IList`1<MediaBrowser.Controller.Entities.BaseItem>)
GetThemeSongs(Jellyfin.Data.Entities.User)
GetThemeSongs(Jellyfin.Data.Entities.User,System.Collections.Generic.IEnumerable`1<System.ValueTuple`2<Jellyfin.Data.Enums.ItemSortBy,Jellyfin.Data.Enums.SortOrder>>)
GetThemeVideos(Jellyfin.Data.Entities.User)
GetThemeVideos(Jellyfin.Data.Entities.User,System.Collections.Generic.IEnumerable`1<System.ValueTuple`2<Jellyfin.Data.Enums.ItemSortBy,Jellyfin.Data.Enums.SortOrder>>)
GetExtras()
GetExtras(System.Collections.Generic.IReadOnlyCollection`1<MediaBrowser.Model.Entities.ExtraType>)
GetRunTimeTicksForPlayState()
Equals(System.Object)
Equals(MediaBrowser.Controller.Entities.BaseItem)
GetHashCode()