jellyfin-server/MediaBrowser.Controller/Entities/TV/Episode.cs

176 lines
5.2 KiB
C#
Raw Normal View History

2013-06-13 15:58:47 +00:00
using System.Collections.Generic;
2013-02-21 01:33:05 +00:00
using System.Linq;
using System.Runtime.Serialization;
namespace MediaBrowser.Controller.Entities.TV
{
/// <summary>
/// Class Episode
/// </summary>
public class Episode : Video
{
/// <summary>
/// Episodes have a special Metadata folder
/// </summary>
/// <value>The meta location.</value>
[IgnoreDataMember]
public override string MetaLocation
{
get
{
return System.IO.Path.Combine(Parent.Path, "metadata");
}
}
[IgnoreDataMember]
protected override bool UseParentPathToCreateResolveArgs
{
get
{
return false;
}
}
2013-02-21 01:33:05 +00:00
/// <summary>
/// We want to group into series not show individually in an index
/// </summary>
/// <value><c>true</c> if [group in index]; otherwise, <c>false</c>.</value>
[IgnoreDataMember]
public override bool GroupInIndex
{
get { return true; }
}
/// <summary>
/// We roll up into series
/// </summary>
/// <value>The index container.</value>
[IgnoreDataMember]
public override Folder IndexContainer
{
get
{
return Season;
}
}
/// <summary>
/// Gets the user data key.
2013-02-21 01:33:05 +00:00
/// </summary>
/// <returns>System.String.</returns>
public override string GetUserDataKey()
2013-02-21 01:33:05 +00:00
{
if (Series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue)
2013-02-21 01:33:05 +00:00
{
return Series.GetUserDataKey() + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000");
2013-02-21 01:33:05 +00:00
}
return base.GetUserDataKey();
2013-02-21 01:33:05 +00:00
}
/// <summary>
/// Override this if you need to combine/collapse person information
/// </summary>
/// <value>All people.</value>
[IgnoreDataMember]
public override IEnumerable<PersonInfo> AllPeople
{
get
{
if (People == null) return Series != null ? Series.People : People;
return Series != null && Series.People != null ? People.Concat(Series.People) : base.AllPeople;
}
}
2013-08-03 14:38:56 +00:00
/// <summary>
/// Gets all genres.
/// </summary>
/// <value>All genres.</value>
2013-02-21 01:33:05 +00:00
[IgnoreDataMember]
2013-08-03 13:24:23 +00:00
public override IEnumerable<string> AllGenres
2013-02-21 01:33:05 +00:00
{
get
{
2013-08-03 13:24:23 +00:00
if (Genres == null) return Series != null ? Series.Genres : Genres;
return Series != null && Series.Genres != null ? Genres.Concat(Series.Genres) : base.AllGenres;
2013-02-21 01:33:05 +00:00
}
}
2013-08-03 14:38:56 +00:00
/// <summary>
/// Gets all studios.
/// </summary>
/// <value>All studios.</value>
2013-02-21 01:33:05 +00:00
[IgnoreDataMember]
2013-08-03 13:24:23 +00:00
public override IEnumerable<string> AllStudios
2013-02-21 01:33:05 +00:00
{
2013-08-03 13:24:23 +00:00
get
2013-02-21 01:33:05 +00:00
{
2013-08-03 13:24:23 +00:00
if (Studios == null) return Series != null ? Series.Studios : Studios;
return Series != null && Series.Studios != null ? Studios.Concat(Series.Studios) : base.AllStudios;
2013-02-21 01:33:05 +00:00
}
}
/// <summary>
/// Our rating comes from our series
/// </summary>
2013-08-03 13:24:23 +00:00
[IgnoreDataMember]
public override string OfficialRatingForComparison
{
2013-08-03 13:24:23 +00:00
get { return Series != null ? Series.OfficialRatingForComparison : base.OfficialRatingForComparison; }
}
/// <summary>
/// Our rating comes from our series
/// </summary>
2013-08-03 13:24:23 +00:00
[IgnoreDataMember]
public override string CustomRatingForComparison
{
2013-08-03 13:24:23 +00:00
get { return Series != null ? Series.CustomRatingForComparison : base.CustomRatingForComparison; }
}
2013-02-21 01:33:05 +00:00
/// <summary>
/// The _series
/// </summary>
private Series _series;
/// <summary>
/// This Episode's Series Instance
/// </summary>
/// <value>The series.</value>
[IgnoreDataMember]
public Series Series
{
get { return _series ?? (_series = FindParent<Series>()); }
}
/// <summary>
/// The _season
/// </summary>
private Season _season;
/// <summary>
/// This Episode's Season Instance
/// </summary>
/// <value>The season.</value>
[IgnoreDataMember]
public Season Season
{
get { return _season ?? (_season = FindParent<Season>()); }
}
/// <summary>
/// This is the ending episode number for double episodes.
/// </summary>
/// <value>The index number.</value>
public int? IndexNumberEnd { get; set; }
/// <summary>
/// Creates the name of the sort.
/// </summary>
/// <returns>System.String.</returns>
protected override string CreateSortName()
{
return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("000-") : "")
+ (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name;
}
2013-02-21 01:33:05 +00:00
}
}