|
|
|
@ -207,7 +207,30 @@ namespace MediaBrowser.Controller.Entities.TV
|
|
|
|
|
{
|
|
|
|
|
var config = user.Configuration;
|
|
|
|
|
|
|
|
|
|
return GetSeasons(user, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes);
|
|
|
|
|
var seriesKey = GetUniqueSeriesKey(this);
|
|
|
|
|
|
|
|
|
|
Logger.Debug("GetSeasons SeriesKey: {0}", seriesKey);
|
|
|
|
|
var query = new InternalItemsQuery(user)
|
|
|
|
|
{
|
|
|
|
|
AncestorWithPresentationUniqueKey = seriesKey,
|
|
|
|
|
IncludeItemTypes = new[] {typeof (Season).Name},
|
|
|
|
|
SortBy = new[] {ItemSortBy.SortName}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
|
|
|
|
|
{
|
|
|
|
|
query.IsVirtualItem = false;
|
|
|
|
|
}
|
|
|
|
|
else if (!config.DisplayMissingEpisodes)
|
|
|
|
|
{
|
|
|
|
|
query.IsMissing = false;
|
|
|
|
|
}
|
|
|
|
|
else if (!config.DisplayUnairedEpisodes)
|
|
|
|
|
{
|
|
|
|
|
query.IsVirtualUnaired = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LibraryManager.GetItemList(query).Cast<Season>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query)
|
|
|
|
@ -241,59 +264,39 @@ namespace MediaBrowser.Controller.Entities.TV
|
|
|
|
|
return Task.FromResult(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Season> GetSeasons(User user, bool includeMissingSeasons, bool includeVirtualUnaired)
|
|
|
|
|
public IEnumerable<Episode> GetEpisodes(User user)
|
|
|
|
|
{
|
|
|
|
|
var seriesKey = GetUniqueSeriesKey(this);
|
|
|
|
|
Logger.Debug("GetEpisodes seriesKey: {0}", seriesKey);
|
|
|
|
|
|
|
|
|
|
Logger.Debug("GetSeasons SeriesKey: {0}", seriesKey);
|
|
|
|
|
var seasons = LibraryManager.GetItemList(new InternalItemsQuery(user)
|
|
|
|
|
var query = new InternalItemsQuery(user)
|
|
|
|
|
{
|
|
|
|
|
AncestorWithPresentationUniqueKey = seriesKey,
|
|
|
|
|
IncludeItemTypes = new[] { typeof(Season).Name },
|
|
|
|
|
SortBy = new[] { ItemSortBy.SortName }
|
|
|
|
|
|
|
|
|
|
}).Cast<Season>().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!includeMissingSeasons)
|
|
|
|
|
IncludeItemTypes = new[] {typeof (Episode).Name, typeof (Season).Name},
|
|
|
|
|
SortBy = new[] {ItemSortBy.SortName}
|
|
|
|
|
};
|
|
|
|
|
var config = user.Configuration;
|
|
|
|
|
if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
|
|
|
|
|
{
|
|
|
|
|
seasons = seasons.Where(i => !(i.IsMissingSeason)).ToList();
|
|
|
|
|
query.IsVirtualItem = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!includeVirtualUnaired)
|
|
|
|
|
else if (!config.DisplayMissingEpisodes)
|
|
|
|
|
{
|
|
|
|
|
seasons = seasons.Where(i => !i.IsVirtualUnaired).ToList();
|
|
|
|
|
query.IsMissing = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return seasons;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Episode> GetEpisodes(User user)
|
|
|
|
|
{
|
|
|
|
|
var config = user.Configuration;
|
|
|
|
|
|
|
|
|
|
return GetEpisodes(user, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Episode> GetEpisodes(User user, bool includeMissing, bool includeVirtualUnaired)
|
|
|
|
|
{
|
|
|
|
|
var seriesKey = GetUniqueSeriesKey(this);
|
|
|
|
|
Logger.Debug("GetEpisodes seriesKey: {0}", seriesKey);
|
|
|
|
|
|
|
|
|
|
var allItems = LibraryManager.GetItemList(new InternalItemsQuery(user)
|
|
|
|
|
else if (!config.DisplayUnairedEpisodes)
|
|
|
|
|
{
|
|
|
|
|
AncestorWithPresentationUniqueKey = seriesKey,
|
|
|
|
|
IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name },
|
|
|
|
|
SortBy = new[] { ItemSortBy.SortName }
|
|
|
|
|
query.IsVirtualUnaired = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
var allItems = LibraryManager.GetItemList(query).ToList();
|
|
|
|
|
|
|
|
|
|
Logger.Debug("GetEpisodes return {0} items from database", allItems.Count);
|
|
|
|
|
|
|
|
|
|
var allSeriesEpisodes = allItems.OfType<Episode>().ToList();
|
|
|
|
|
|
|
|
|
|
var allEpisodes = allItems.OfType<Season>()
|
|
|
|
|
.SelectMany(i => i.GetEpisodes(this, user, includeMissing, includeVirtualUnaired, allSeriesEpisodes))
|
|
|
|
|
.SelectMany(i => i.GetEpisodes(this, user, allSeriesEpisodes))
|
|
|
|
|
.Reverse()
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
@ -370,13 +373,6 @@ namespace MediaBrowser.Controller.Entities.TV
|
|
|
|
|
progress.Report(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season season)
|
|
|
|
|
{
|
|
|
|
|
var config = user.Configuration;
|
|
|
|
|
|
|
|
|
|
return GetSeasonEpisodes(user, season, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<Episode> GetAllEpisodes(User user)
|
|
|
|
|
{
|
|
|
|
|
Logger.Debug("Series.GetAllEpisodes entering GetItemList");
|
|
|
|
@ -394,62 +390,51 @@ namespace MediaBrowser.Controller.Entities.TV
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes)
|
|
|
|
|
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season parentSeason)
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<Episode> episodes = GetAllEpisodes(user);
|
|
|
|
|
|
|
|
|
|
return GetSeasonEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes, episodes);
|
|
|
|
|
}
|
|
|
|
|
var seriesKey = GetUniqueSeriesKey(this);
|
|
|
|
|
Logger.Debug("GetSeasonEpisodes seriesKey: {0}", seriesKey);
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable<Episode> allSeriesEpisodes)
|
|
|
|
|
{
|
|
|
|
|
if (allSeriesEpisodes == null)
|
|
|
|
|
var query = new InternalItemsQuery(user)
|
|
|
|
|
{
|
|
|
|
|
Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null");
|
|
|
|
|
return GetSeasonEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes);
|
|
|
|
|
AncestorWithPresentationUniqueKey = seriesKey,
|
|
|
|
|
IncludeItemTypes = new[] { typeof(Episode).Name },
|
|
|
|
|
SortBy = new[] { ItemSortBy.SortName }
|
|
|
|
|
};
|
|
|
|
|
var config = user.Configuration;
|
|
|
|
|
if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
|
|
|
|
|
{
|
|
|
|
|
query.IsVirtualItem = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason");
|
|
|
|
|
var episodes = FilterEpisodesBySeason(allSeriesEpisodes, parentSeason, ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons);
|
|
|
|
|
|
|
|
|
|
if (!includeMissingEpisodes)
|
|
|
|
|
else if (!config.DisplayMissingEpisodes)
|
|
|
|
|
{
|
|
|
|
|
episodes = episodes.Where(i => !i.IsMissingEpisode);
|
|
|
|
|
query.IsMissing = false;
|
|
|
|
|
}
|
|
|
|
|
if (!includeVirtualUnairedEpisodes)
|
|
|
|
|
else if (!config.DisplayUnairedEpisodes)
|
|
|
|
|
{
|
|
|
|
|
episodes = episodes.Where(i => !i.IsVirtualUnaired);
|
|
|
|
|
query.IsVirtualUnaired = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortBy = (parentSeason.IndexNumber ?? -1) == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder;
|
|
|
|
|
var allItems = LibraryManager.GetItemList(query).OfType<Episode>();
|
|
|
|
|
|
|
|
|
|
return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending)
|
|
|
|
|
.Cast<Episode>();
|
|
|
|
|
return GetSeasonEpisodes(user, parentSeason, allItems);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Filters the episodes by season.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IEnumerable<Episode> FilterEpisodesBySeason(IEnumerable<Episode> episodes, int seasonNumber, bool includeSpecials)
|
|
|
|
|
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season parentSeason, IEnumerable<Episode> allSeriesEpisodes)
|
|
|
|
|
{
|
|
|
|
|
if (!includeSpecials || seasonNumber < 1)
|
|
|
|
|
if (allSeriesEpisodes == null)
|
|
|
|
|
{
|
|
|
|
|
return episodes.Where(i => (i.ParentIndexNumber ?? -1) == seasonNumber);
|
|
|
|
|
Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null");
|
|
|
|
|
return GetSeasonEpisodes(user, parentSeason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return episodes.Where(i =>
|
|
|
|
|
{
|
|
|
|
|
var episode = i;
|
|
|
|
|
|
|
|
|
|
if (episode != null)
|
|
|
|
|
{
|
|
|
|
|
var currentSeasonNumber = episode.AiredSeasonNumber;
|
|
|
|
|
Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason");
|
|
|
|
|
var episodes = FilterEpisodesBySeason(allSeriesEpisodes, parentSeason, ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons);
|
|
|
|
|
|
|
|
|
|
return currentSeasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber;
|
|
|
|
|
}
|
|
|
|
|
var sortBy = (parentSeason.IndexNumber ?? -1) == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending)
|
|
|
|
|
.Cast<Episode>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -480,6 +465,32 @@ namespace MediaBrowser.Controller.Entities.TV
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Filters the episodes by season.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IEnumerable<Episode> FilterEpisodesBySeason(IEnumerable<Episode> episodes, int seasonNumber, bool includeSpecials)
|
|
|
|
|
{
|
|
|
|
|
if (!includeSpecials || seasonNumber < 1)
|
|
|
|
|
{
|
|
|
|
|
return episodes.Where(i => (i.ParentIndexNumber ?? -1) == seasonNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return episodes.Where(i =>
|
|
|
|
|
{
|
|
|
|
|
var episode = i;
|
|
|
|
|
|
|
|
|
|
if (episode != null)
|
|
|
|
|
{
|
|
|
|
|
var currentSeasonNumber = episode.AiredSeasonNumber;
|
|
|
|
|
|
|
|
|
|
return currentSeasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
|
|
|
|
{
|
|
|
|
|
return config.BlockUnratedItems.Contains(UnratedItem.Series);
|
|
|
|
|