using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace MediaBrowser.Controller.Entities.TV
{
///
/// Class Episode
///
public class Episode : Video
{
///
/// Episodes have a special Metadata folder
///
/// The meta location.
[IgnoreDataMember]
public override string MetaLocation
{
get
{
return System.IO.Path.Combine(Parent.Path, "metadata");
}
}
///
/// We want to group into series not show individually in an index
///
/// true if [group in index]; otherwise, false.
[IgnoreDataMember]
public override bool GroupInIndex
{
get { return true; }
}
///
/// We roll up into series
///
/// The index container.
[IgnoreDataMember]
public override Folder IndexContainer
{
get
{
return Season;
}
}
///
/// Gets the user data key.
///
/// System.String.
public override string GetUserDataKey()
{
if (Series != null)
{
var seasonNo = Season != null ? Season.IndexNumber ?? 0 : 0;
var epNo = IndexNumber ?? 0;
return Series.GetUserDataKey() + seasonNo.ToString("000") + epNo.ToString("000");
}
return base.GetUserDataKey();
}
///
/// Override this if you need to combine/collapse person information
///
/// All people.
[IgnoreDataMember]
public override IEnumerable AllPeople
{
get
{
if (People == null) return Series != null ? Series.People : People;
return Series != null && Series.People != null ? People.Concat(Series.People) : base.AllPeople;
}
}
///
/// Gets or sets the studios.
///
/// The studios.
[IgnoreDataMember]
public override List Studios
{
get
{
return Series != null ? Series.Studios : null;
}
set
{
base.Studios = value;
}
}
///
/// Gets or sets the genres.
///
/// The genres.
[IgnoreDataMember]
public override List Genres
{
get { return Series != null ? Series.Genres : null; }
set
{
base.Genres = value;
}
}
///
/// 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;
}
}
///
/// 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; }
///
/// We persist the MB Id of our season object so we can always find it no matter
/// what context we happen to be loaded from.
///
/// The season item id.
public Guid SeasonItemId { get; set; }
///
/// The _series
///
private Series _series;
///
/// This Episode's Series Instance
///
/// The series.
[IgnoreDataMember]
public Series Series
{
get { return _series ?? (_series = FindParent()); }
}
///
/// The _season
///
private Season _season;
///
/// This Episode's Season Instance
///
/// The season.
[IgnoreDataMember]
public Season Season
{
get { return _season ?? (_season = FindParent()); }
}
///
/// Creates the name of the sort.
///
/// System.String.
protected override string CreateSortName()
{
return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("000-") : "")
+ (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name;
}
}
}