2013-10-26 22:01:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-15 16:21:32 +00:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
protected override bool UseParentPathToCreateResolveArgs
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-08-18 13:39:27 +00:00
|
|
|
|
return false;
|
2013-08-15 16:21:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-15 21:31:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the season in which it aired.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The aired season.</value>
|
2013-11-17 15:27:48 +00:00
|
|
|
|
public int? AirsBeforeSeasonNumber { get; set; }
|
|
|
|
|
public int? AirsAfterSeasonNumber { get; set; }
|
|
|
|
|
public int? AirsBeforeEpisodeNumber { get; set; }
|
2013-11-15 21:31:33 +00:00
|
|
|
|
|
2013-12-08 18:07:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the DVD season number.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The DVD season number.</value>
|
|
|
|
|
public int? DvdSeasonNumber { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the DVD episode number.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The DVD episode number.</value>
|
2013-12-08 22:16:59 +00:00
|
|
|
|
public float? DvdEpisodeNumber { get; set; }
|
2013-12-08 18:07:45 +00:00
|
|
|
|
|
2013-12-10 20:42:42 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the absolute episode number.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The absolute episode number.</value>
|
|
|
|
|
public int? AbsoluteEpisodeNumber { get; set; }
|
|
|
|
|
|
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; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-22 15:33:14 +00:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public int? AiredSeasonNumber
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-11-23 20:01:09 +00:00
|
|
|
|
return AirsAfterSeasonNumber ?? AirsBeforeSeasonNumber ?? PhysicalSeasonNumber;
|
2013-11-22 15:33:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public int? PhysicalSeasonNumber
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var value = ParentIndexNumber;
|
|
|
|
|
|
|
|
|
|
if (value.HasValue)
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var season = Parent as Season;
|
|
|
|
|
|
|
|
|
|
return season != null ? season.IndexNumber : null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// We roll up into series
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The index container.</value>
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override Folder IndexContainer
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-12-03 21:12:20 +00:00
|
|
|
|
return FindParent<Season>();
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-04-13 18:02:30 +00:00
|
|
|
|
/// Gets the user data key.
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// </summary>
|
2013-04-13 18:02:30 +00:00
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public override string GetUserDataKey()
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-06-05 01:19:25 +00:00
|
|
|
|
if (Series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-06-05 01:19:25 +00:00
|
|
|
|
return Series.GetUserDataKey() + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000");
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
2013-04-13 18:02:30 +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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-27 00:28:07 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Our rating comes from our series
|
|
|
|
|
/// </summary>
|
2013-08-03 13:24:23 +00:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override string OfficialRatingForComparison
|
2013-03-27 00:28:07 +00:00
|
|
|
|
{
|
2013-08-03 13:24:23 +00:00
|
|
|
|
get { return Series != null ? Series.OfficialRatingForComparison : base.OfficialRatingForComparison; }
|
2013-03-27 00:28:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Our rating comes from our series
|
|
|
|
|
/// </summary>
|
2013-08-03 13:24:23 +00:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override string CustomRatingForComparison
|
2013-03-27 00:28:07 +00:00
|
|
|
|
{
|
2013-08-03 13:24:23 +00:00
|
|
|
|
get { return Series != null ? Series.CustomRatingForComparison : base.CustomRatingForComparison; }
|
2013-03-27 00:28:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
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>
|
2013-05-24 02:05:31 +00:00
|
|
|
|
/// This is the ending episode number for double episodes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The index number.</value>
|
|
|
|
|
public int? IndexNumberEnd { get; set; }
|
|
|
|
|
|
2013-03-12 01:46:46 +00:00
|
|
|
|
/// <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-10-15 22:16:26 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether [contains episode number] [the specified number].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="number">The number.</param>
|
|
|
|
|
/// <returns><c>true</c> if [contains episode number] [the specified number]; otherwise, <c>false</c>.</returns>
|
|
|
|
|
public bool ContainsEpisodeNumber(int number)
|
|
|
|
|
{
|
|
|
|
|
if (IndexNumber.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (IndexNumberEnd.HasValue)
|
|
|
|
|
{
|
|
|
|
|
return number >= IndexNumber.Value && number <= IndexNumberEnd.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return IndexNumber.Value == number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-10-26 22:01:21 +00:00
|
|
|
|
|
2013-11-12 15:36:08 +00:00
|
|
|
|
[IgnoreDataMember]
|
2013-10-26 22:01:21 +00:00
|
|
|
|
public bool IsMissingEpisode
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return LocationType == Model.Entities.LocationType.Virtual && PremiereDate.HasValue && PremiereDate.Value < DateTime.UtcNow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-12 15:36:08 +00:00
|
|
|
|
[IgnoreDataMember]
|
2013-10-26 22:01:21 +00:00
|
|
|
|
public bool IsUnaired
|
|
|
|
|
{
|
2013-10-28 12:26:00 +00:00
|
|
|
|
get { return PremiereDate.HasValue && PremiereDate.Value.ToLocalTime().Date >= DateTime.Now.Date; }
|
2013-10-26 22:40:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-12 15:36:08 +00:00
|
|
|
|
[IgnoreDataMember]
|
2013-10-26 22:40:53 +00:00
|
|
|
|
public bool IsVirtualUnaired
|
|
|
|
|
{
|
|
|
|
|
get { return LocationType == Model.Entities.LocationType.Virtual && IsUnaired; }
|
2013-10-26 22:01:21 +00:00
|
|
|
|
}
|
2013-12-01 19:31:58 +00:00
|
|
|
|
|
2013-12-04 04:18:50 +00:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public Guid? SeasonId
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// First see if the parent is a Season
|
|
|
|
|
var season = Parent as Season;
|
|
|
|
|
|
|
|
|
|
if (season != null)
|
|
|
|
|
{
|
|
|
|
|
return season.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var seasonNumber = ParentIndexNumber;
|
|
|
|
|
|
|
|
|
|
// Parent is a Series
|
|
|
|
|
if (seasonNumber.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var series = Parent as Series;
|
|
|
|
|
|
|
|
|
|
if (series != null)
|
|
|
|
|
{
|
|
|
|
|
season = series.Children.OfType<Season>()
|
|
|
|
|
.FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber.Value);
|
|
|
|
|
|
|
|
|
|
if (season != null)
|
|
|
|
|
{
|
|
|
|
|
return season.Id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-01 19:31:58 +00:00
|
|
|
|
public override IEnumerable<string> GetDeletePaths()
|
|
|
|
|
{
|
|
|
|
|
return new[] { Path };
|
|
|
|
|
}
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|