using System.Collections.Generic; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Common.Win32; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; using MediaBrowser.Model.Entities; using System; using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities.TV { /// /// Class Season /// public class Season : Folder { /// /// Seasons are just containers /// /// true if [include in index]; otherwise, false. [IgnoreDataMember] public override bool IncludeInIndex { get { return false; } } /// /// We want to group into our Series /// /// true if [group in index]; otherwise, false. [IgnoreDataMember] public override bool GroupInIndex { get { return true; } } /// /// Override this to return the folder that should be used to construct a container /// for this item in an index. GroupInIndex should be true as well. /// /// The index container. [IgnoreDataMember] public override Folder IndexContainer { get { return Series; } } // Genre, Rating and Stuido will all be the same protected override Dictionary>> GetIndexByOptions() { return new Dictionary>> { {LocalizedStrings.Instance.GetString("NoneDispPref"), null}, {LocalizedStrings.Instance.GetString("PerformerDispPref"), GetIndexByPerformer}, {LocalizedStrings.Instance.GetString("DirectorDispPref"), GetIndexByDirector}, {LocalizedStrings.Instance.GetString("YearDispPref"), GetIndexByYear}, }; } /// /// Override to use the provider Ids + season number so it will be portable /// /// The user data id. [IgnoreDataMember] public override Guid UserDataId { get { if (_userDataId == Guid.Empty) { var baseId = Series != null ? Series.GetProviderId(MetadataProviders.Tvdb) ?? Series.GetProviderId(MetadataProviders.Tvcom) : null; if (baseId != null) { var seasonNo = IndexNumber ?? 0; baseId = baseId + seasonNo.ToString("000"); } _userDataId = baseId != null ? baseId.GetMD5() : Id; } return _userDataId; } } /// /// We persist the MB Id of our series object so we can always find it no matter /// what context we happen to be loaded from. /// /// The series item id. public Guid SeriesItemId { get; set; } /// /// The _series /// private Series _series; /// /// This Episode's Series Instance /// /// The series. [IgnoreDataMember] public Series Series { get { return _series ?? (_series = FindParent()); } } /// /// Add files from the metadata folder to ResolveArgs /// /// The args. internal static void AddMetadataFiles(ItemResolveArgs args) { var folder = args.GetFileSystemEntryByName("metadata"); if (folder.HasValue) { args.AddMetadataFiles(FileSystem.GetFiles(folder.Value.Path)); } } /// /// Creates ResolveArgs on demand /// /// The path info. /// ItemResolveArgs. protected internal override ItemResolveArgs CreateResolveArgs(WIN32_FIND_DATA? pathInfo = null) { var args = base.CreateResolveArgs(pathInfo); AddMetadataFiles(args); return args; } } }