using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.Entities { /// /// Interface IHasMetadata /// public interface IHasMetadata : IHasProviderIds, IHasUserData { /// /// Gets the preferred metadata country code. /// /// System.String. string GetPreferredMetadataCountryCode(); /// /// Gets the date modified. /// /// The date modified. DateTime DateModified { get; set; } /// /// Gets or sets the date last saved. /// /// The date last saved. DateTime DateLastSaved { get; set; } SourceType SourceType { get; } /// /// Gets or sets the date last refreshed. /// /// The date last refreshed. DateTime DateLastRefreshed { get; set; } /// /// This is called before any metadata refresh and returns true or false indicating if changes were made /// /// true if XXXX, false otherwise. bool BeforeMetadataRefresh(); /// /// Afters the metadata refresh. /// void AfterMetadataRefresh(); /// /// Gets a value indicating whether [supports people]. /// /// true if [supports people]; otherwise, false. bool SupportsPeople { get; } bool RequiresRefresh(); bool EnableRefreshOnDateModifiedChange { get; } string PresentationUniqueKey { get; set; } string GetPresentationUniqueKey(); string CreatePresentationUniqueKey(); bool StopRefreshIfLocalMetadataFound { get; } int? GetInheritedParentalRatingValue(); int InheritedParentalRatingValue { get; set; } List GetInheritedTags(); long? RunTimeTicks { get; set; } /// /// Gets the name. /// /// The name. string Name { get; set; } /// /// Gets the path. /// /// The path. string Path { get; set; } /// /// Gets the file name without extension. /// /// The file name without extension. string FileNameWithoutExtension { get; } /// /// Gets the type of the location. /// /// The type of the location. LocationType LocationType { get; } /// /// Gets the locked fields. /// /// The locked fields. MetadataFields[] LockedFields { get; } /// /// Gets the images. /// /// Type of the image. /// IEnumerable{ItemImageInfo}. IEnumerable GetImages(ImageType imageType); /// /// Gets the image path. /// /// Type of the image. /// Index of the image. /// System.String. string GetImagePath(ImageType imageType, int imageIndex); /// /// Gets the image information. /// /// Type of the image. /// Index of the image. /// ItemImageInfo. ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex); /// /// Sets the image. /// /// The type. /// The index. /// The file. void SetImagePath(ImageType type, int index, FileSystemMetadata file); /// /// Determines whether the specified type has image. /// /// The type. /// Index of the image. /// true if the specified type has image; otherwise, false. bool HasImage(ImageType type, int imageIndex); /// /// Allowses the multiple images. /// /// The type. /// true if XXXX, false otherwise. bool AllowsMultipleImages(ImageType type); /// /// Swaps the images. /// void SwapImages(ImageType type, int index1, int index2); /// /// Gets or sets the primary image path. /// /// The primary image path. string PrimaryImagePath { get; } /// /// Gets the preferred metadata language. /// /// System.String. string GetPreferredMetadataLanguage(); /// /// Validates the images and returns true or false indicating if any were removed. /// bool ValidateImages(IDirectoryService directoryService); /// /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. bool IsOwnedItem { get; } /// /// Gets the containing folder path. /// /// The containing folder path. string ContainingFolderPath { get; } /// /// Adds the images. /// /// Type of the image. /// The images. /// true if XXXX, false otherwise. bool AddImages(ImageType imageType, List images); /// /// Determines whether [is save local metadata enabled]. /// /// true if [is save local metadata enabled]; otherwise, false. bool IsSaveLocalMetadataEnabled(); /// /// Gets a value indicating whether [supports local metadata]. /// /// true if [supports local metadata]; otherwise, false. bool SupportsLocalMetadata { get; } bool IsInMixedFolder { get; } /// /// Gets a value indicating whether this instance is locked. /// /// true if this instance is locked; otherwise, false. bool IsLocked { get; } /// /// Gets a value indicating whether [supports remote image downloading]. /// /// true if [supports remote image downloading]; otherwise, false. bool SupportsRemoteImageDownloading { get; } /// /// Gets the internal metadata path. /// /// System.String. string GetInternalMetadataPath(); /// /// Gets a value indicating whether [always scan internal metadata path]. /// /// true if [always scan internal metadata path]; otherwise, false. bool AlwaysScanInternalMetadataPath { get; } /// /// Determines whether [is internet metadata enabled]. /// /// true if [is internet metadata enabled]; otherwise, false. bool IsInternetMetadataEnabled(); /// /// Removes the image. /// /// The image. void RemoveImage(ItemImageInfo image); void RemoveImages(List images); /// /// Updates to repository. /// void UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken); /// /// Sets the image. /// /// The image. /// The index. void SetImage(ItemImageInfo image, int index); double? GetDefaultPrimaryImageAspectRatio(); int? ProductionYear { get; set; } string[] Tags { get; set; } ItemUpdateType OnMetadataChanged(); } public static class HasMetadataExtensions { /// /// Gets the image path. /// /// The item. /// Type of the image. /// System.String. public static string GetImagePath(this IHasMetadata item, ImageType imageType) { return item.GetImagePath(imageType, 0); } public static bool HasImage(this IHasMetadata item, ImageType imageType) { return item.HasImage(imageType, 0); } /// /// Sets the image path. /// /// The item. /// Type of the image. /// The file. public static void SetImagePath(this IHasMetadata item, ImageType imageType, FileSystemMetadata file) { item.SetImagePath(imageType, 0, file); } /// /// Sets the image path. /// /// The item. /// Type of the image. /// The file. public static void SetImagePath(this IHasMetadata item, ImageType imageType, string file) { if (file.StartsWith("http", System.StringComparison.OrdinalIgnoreCase)) { item.SetImage(new ItemImageInfo { Path = file, Type = imageType }, 0); } else { item.SetImagePath(imageType, BaseItem.FileSystem.GetFileInfo(file)); } } } }