using System.Collections.Generic;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.IO;
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},
};
}
///
/// Gets the user data key.
///
/// System.String.
public override string GetUserDataKey()
{
if (Series != null)
{
var seasonNo = IndexNumber ?? 0;
return Series.GetUserDataKey() + seasonNo.ToString("000");
}
return base.GetUserDataKey();
}
///
/// 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()); }
}
///
/// Our rating comes from our series
///
public override string OfficialRating
{
get { return Series != null ? Series.OfficialRating : base.OfficialRating; }
set
{
base.OfficialRating = value;
}
}
///
/// Our rating comes from our series
///
public override string CustomRating
{
get { return Series != null ? Series.CustomRating : base.CustomRating; }
set
{
base.CustomRating = value;
}
}
///
/// Add files from the metadata folder to ResolveArgs
///
/// The args.
public 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;
}
///
/// Creates the name of the sort.
///
/// System.String.
protected override string CreateSortName()
{
return IndexNumber != null ? IndexNumber.Value.ToString("0000") : Name;
}
}
}