update season cleanup
This commit is contained in:
parent
2d7c82d0dd
commit
f646c0f29d
|
@ -478,7 +478,7 @@ namespace MediaBrowser.Api
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
episodes = series.GetSeasonEpisodes(user, season);
|
episodes = series.GetSeasonEpisodes(season, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -185,34 +185,12 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
|
|
||||||
public IEnumerable<Episode> GetEpisodes(Series series, User user, IEnumerable<Episode> allSeriesEpisodes)
|
public IEnumerable<Episode> GetEpisodes(Series series, User user, IEnumerable<Episode> allSeriesEpisodes)
|
||||||
{
|
{
|
||||||
return series.GetSeasonEpisodes(user, this, allSeriesEpisodes);
|
return series.GetSeasonEpisodes(this, user, allSeriesEpisodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Episode> GetEpisodes()
|
public IEnumerable<Episode> GetEpisodes()
|
||||||
{
|
{
|
||||||
var episodes = GetRecursiveChildren().OfType<Episode>();
|
return Series.GetSeasonEpisodes(this, null, null);
|
||||||
var series = Series;
|
|
||||||
|
|
||||||
if (series != null && series.ContainsEpisodesWithoutSeasonFolders)
|
|
||||||
{
|
|
||||||
var seasonNumber = IndexNumber;
|
|
||||||
var list = episodes.ToList();
|
|
||||||
|
|
||||||
if (seasonNumber.HasValue)
|
|
||||||
{
|
|
||||||
list.AddRange(series.GetRecursiveChildren().OfType<Episode>()
|
|
||||||
.Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == seasonNumber.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list.AddRange(series.GetRecursiveChildren().OfType<Episode>()
|
|
||||||
.Where(i => !i.ParentIndexNumber.HasValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
episodes = list.DistinctBy(i => i.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return episodes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
||||||
|
|
|
@ -373,24 +373,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Episode> GetAllEpisodes(User user)
|
public IEnumerable<Episode> GetSeasonEpisodes(Season parentSeason, User user)
|
||||||
{
|
|
||||||
Logger.Debug("Series.GetAllEpisodes entering GetItemList");
|
|
||||||
|
|
||||||
var result = LibraryManager.GetItemList(new InternalItemsQuery(user)
|
|
||||||
{
|
|
||||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
|
|
||||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
|
||||||
SortBy = new[] { ItemSortBy.SortName }
|
|
||||||
|
|
||||||
}).Cast<Episode>().ToList();
|
|
||||||
|
|
||||||
Logger.Debug("Series.GetAllEpisodes returning {0} episodes", result.Count);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season parentSeason)
|
|
||||||
{
|
{
|
||||||
var seriesKey = GetUniqueSeriesKey(this);
|
var seriesKey = GetUniqueSeriesKey(this);
|
||||||
Logger.Debug("GetSeasonEpisodes seriesKey: {0}", seriesKey);
|
Logger.Debug("GetSeasonEpisodes seriesKey: {0}", seriesKey);
|
||||||
|
@ -401,31 +384,34 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||||
SortBy = new[] { ItemSortBy.SortName }
|
SortBy = new[] { ItemSortBy.SortName }
|
||||||
};
|
};
|
||||||
var config = user.Configuration;
|
if (user != null)
|
||||||
if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
|
|
||||||
{
|
{
|
||||||
query.IsVirtualItem = false;
|
var config = user.Configuration;
|
||||||
}
|
if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
|
||||||
else if (!config.DisplayMissingEpisodes)
|
{
|
||||||
{
|
query.IsVirtualItem = false;
|
||||||
query.IsMissing = false;
|
}
|
||||||
}
|
else if (!config.DisplayMissingEpisodes)
|
||||||
else if (!config.DisplayUnairedEpisodes)
|
{
|
||||||
{
|
query.IsMissing = false;
|
||||||
query.IsVirtualUnaired = false;
|
}
|
||||||
|
else if (!config.DisplayUnairedEpisodes)
|
||||||
|
{
|
||||||
|
query.IsVirtualUnaired = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var allItems = LibraryManager.GetItemList(query).OfType<Episode>();
|
var allItems = LibraryManager.GetItemList(query).OfType<Episode>();
|
||||||
|
|
||||||
return GetSeasonEpisodes(user, parentSeason, allItems);
|
return GetSeasonEpisodes(parentSeason, user, allItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season parentSeason, IEnumerable<Episode> allSeriesEpisodes)
|
public IEnumerable<Episode> GetSeasonEpisodes(Season parentSeason, User user, IEnumerable<Episode> allSeriesEpisodes)
|
||||||
{
|
{
|
||||||
if (allSeriesEpisodes == null)
|
if (allSeriesEpisodes == null)
|
||||||
{
|
{
|
||||||
Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null");
|
Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null");
|
||||||
return GetSeasonEpisodes(user, parentSeason);
|
return GetSeasonEpisodes(parentSeason, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason");
|
Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason");
|
||||||
|
|
|
@ -138,8 +138,6 @@ namespace MediaBrowser.Providers.TV
|
||||||
.Where(i => i.LocationType == LocationType.Virtual)
|
.Where(i => i.LocationType == LocationType.Virtual)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var episodes = series.GetRecursiveChildren().OfType<Episode>().ToList();
|
|
||||||
|
|
||||||
var seasonsToRemove = virtualSeasons
|
var seasonsToRemove = virtualSeasons
|
||||||
.Where(i =>
|
.Where(i =>
|
||||||
{
|
{
|
||||||
|
@ -152,19 +150,15 @@ namespace MediaBrowser.Providers.TV
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are no episodes with this season number, delete it
|
|
||||||
if (episodes.All(e => !e.ParentIndexNumber.HasValue || e.ParentIndexNumber.Value != seasonNumber))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Season does not have a number
|
// If there are no episodes with this season number, delete it
|
||||||
// Remove if there are no episodes directly in series without a season number
|
if (!i.GetEpisodes().Any())
|
||||||
return episodes.All(s => s.ParentIndexNumber.HasValue || s.IsInSeasonFolder);
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user