mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
update season cleanup
This commit is contained in:
parent
2d7c82d0dd
commit
f646c0f29d
@ -478,7 +478,7 @@ namespace MediaBrowser.Api
|
||||
}
|
||||
else
|
||||
{
|
||||
episodes = series.GetSeasonEpisodes(user, season);
|
||||
episodes = series.GetSeasonEpisodes(season, user);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -185,34 +185,12 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
|
||||
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()
|
||||
{
|
||||
var episodes = GetRecursiveChildren().OfType<Episode>();
|
||||
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;
|
||||
return Series.GetSeasonEpisodes(this, null, null);
|
||||
}
|
||||
|
||||
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
||||
|
@ -373,24 +373,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
private IEnumerable<Episode> GetAllEpisodes(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)
|
||||
public IEnumerable<Episode> GetSeasonEpisodes(Season parentSeason, User user)
|
||||
{
|
||||
var seriesKey = GetUniqueSeriesKey(this);
|
||||
Logger.Debug("GetSeasonEpisodes seriesKey: {0}", seriesKey);
|
||||
@ -401,31 +384,34 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName }
|
||||
};
|
||||
var config = user.Configuration;
|
||||
if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
|
||||
if (user != null)
|
||||
{
|
||||
query.IsVirtualItem = false;
|
||||
}
|
||||
else if (!config.DisplayMissingEpisodes)
|
||||
{
|
||||
query.IsMissing = false;
|
||||
}
|
||||
else if (!config.DisplayUnairedEpisodes)
|
||||
{
|
||||
query.IsVirtualUnaired = false;
|
||||
var config = user.Configuration;
|
||||
if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
|
||||
{
|
||||
query.IsVirtualItem = false;
|
||||
}
|
||||
else if (!config.DisplayMissingEpisodes)
|
||||
{
|
||||
query.IsMissing = false;
|
||||
}
|
||||
else if (!config.DisplayUnairedEpisodes)
|
||||
{
|
||||
query.IsVirtualUnaired = false;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null");
|
||||
return GetSeasonEpisodes(user, parentSeason);
|
||||
return GetSeasonEpisodes(parentSeason, user);
|
||||
}
|
||||
|
||||
Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason");
|
||||
|
@ -138,8 +138,6 @@ namespace MediaBrowser.Providers.TV
|
||||
.Where(i => i.LocationType == LocationType.Virtual)
|
||||
.ToList();
|
||||
|
||||
var episodes = series.GetRecursiveChildren().OfType<Episode>().ToList();
|
||||
|
||||
var seasonsToRemove = virtualSeasons
|
||||
.Where(i =>
|
||||
{
|
||||
@ -152,19 +150,15 @@ namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
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
|
||||
// Remove if there are no episodes directly in series without a season number
|
||||
return episodes.All(s => s.ParentIndexNumber.HasValue || s.IsInSeasonFolder);
|
||||
// If there are no episodes with this season number, delete it
|
||||
if (!i.GetEpisodes().Any())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user