@ -250,7 +250,7 @@ namespace MediaBrowser.Controller.Entities.TV
return LibraryManager . GetItemsResult ( query ) ;
}
public IEnumerable < BaseItem > GetEpisodes ( User user , DtoOptions options )
public IEnumerable < BaseItem > GetEpisodes ( User user , DtoOptions options , bool shouldIncludeMissingEpisodes )
{
var seriesKey = GetUniqueSeriesKey ( this ) ;
@ -260,20 +260,16 @@ namespace MediaBrowser.Controller.Entities.TV
SeriesPresentationUniqueKey = seriesKey ,
IncludeItemTypes = new [ ] { BaseItemKind . Episode , BaseItemKind . Season } ,
OrderBy = new [ ] { ( ItemSortBy . SortName , SortOrder . Ascending ) } ,
DtoOptions = options
DtoOptions = options ,
IsMissing = shouldIncludeMissingEpisodes
} ;
if ( user is null | | ! user . DisplayMissingEpisodes )
{
query . IsMissing = false ;
}
var allItems = LibraryManager . GetItemList ( query ) ;
var allSeriesEpisodes = allItems . OfType < Episode > ( ) . ToList ( ) ;
var allEpisodes = allItems . OfType < Season > ( )
. SelectMany ( i = > i . GetEpisodes ( this , user , allSeriesEpisodes , options ))
. SelectMany ( i = > i . GetEpisodes ( this , user , allSeriesEpisodes , options , shouldIncludeMissingEpisodes ))
. Reverse ( ) ;
// Specials could appear twice based on above - once in season 0, once in the aired season
@ -348,7 +344,7 @@ namespace MediaBrowser.Controller.Entities.TV
await ProviderManager . RefreshSingleItem ( this , refreshOptions , cancellationToken ) . ConfigureAwait ( false ) ;
}
public List < BaseItem > GetSeasonEpisodes ( Season parentSeason , User user , DtoOptions options )
public List < BaseItem > GetSeasonEpisodes ( Season parentSeason , User user , DtoOptions options , bool shouldIncludeMissingEpisodes )
{
var queryFromSeries = ConfigurationManager . Configuration . DisplaySpecialsWithinSeasons ;
@ -363,26 +359,20 @@ namespace MediaBrowser.Controller.Entities.TV
SeriesPresentationUniqueKey = queryFromSeries ? seriesKey : null ,
IncludeItemTypes = new [ ] { BaseItemKind . Episode } ,
OrderBy = new [ ] { ( ItemSortBy . SortName , SortOrder . Ascending ) } ,
DtoOptions = options
DtoOptions = options ,
IsMissing = shouldIncludeMissingEpisodes
} ;
if ( user is not null )
{
if ( ! user . DisplayMissingEpisodes )
{
query . IsMissing = false ;
}
}
var allItems = LibraryManager . GetItemList ( query ) ;
return GetSeasonEpisodes ( parentSeason , user , allItems , options );
return GetSeasonEpisodes ( parentSeason , user , allItems , options , shouldIncludeMissingEpisodes ) ;
}
public List < BaseItem > GetSeasonEpisodes ( Season parentSeason , User user , IEnumerable < BaseItem > allSeriesEpisodes , DtoOptions options )
public List < BaseItem > GetSeasonEpisodes ( Season parentSeason , User user , IEnumerable < BaseItem > allSeriesEpisodes , DtoOptions options , bool shouldIncludeMissingEpisodes )
{
if ( allSeriesEpisodes is null )
{
return GetSeasonEpisodes ( parentSeason , user , options );
return GetSeasonEpisodes ( parentSeason , user , options , shouldIncludeMissingEpisodes );
}
var episodes = FilterEpisodesBySeason ( allSeriesEpisodes , parentSeason , ConfigurationManager . Configuration . DisplaySpecialsWithinSeasons ) ;