support getting all episodes per series
This commit is contained in:
parent
6f59f6cd92
commit
bed6bed5c6
|
@ -413,7 +413,18 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
IEnumerable<Episode> episodes;
|
IEnumerable<Episode> episodes;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(request.SeasonId))
|
if (!string.IsNullOrWhiteSpace(request.SeasonId))
|
||||||
|
{
|
||||||
|
var season = _libraryManager.GetItemById(new Guid(request.SeasonId)) as Season;
|
||||||
|
|
||||||
|
if (season == null)
|
||||||
|
{
|
||||||
|
throw new ResourceNotFoundException("No season exists with Id " + request.SeasonId);
|
||||||
|
}
|
||||||
|
|
||||||
|
episodes = season.GetEpisodes(user);
|
||||||
|
}
|
||||||
|
else if (request.Season.HasValue)
|
||||||
{
|
{
|
||||||
var series = _libraryManager.GetItemById(request.Id) as Series;
|
var series = _libraryManager.GetItemById(request.Id) as Series;
|
||||||
|
|
||||||
|
@ -426,14 +437,14 @@ namespace MediaBrowser.Api
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var season = _libraryManager.GetItemById(new Guid(request.SeasonId)) as Season;
|
var series = _libraryManager.GetItemById(request.Id) as Series;
|
||||||
|
|
||||||
if (season == null)
|
if (series == null)
|
||||||
{
|
{
|
||||||
throw new ResourceNotFoundException("No season exists with Id " + request.SeasonId);
|
throw new ResourceNotFoundException("No series exists with Id " + request.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
episodes = season.GetEpisodes(user);
|
episodes = series.GetEpisodes(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter after the fact in case the ui doesn't want them
|
// Filter after the fact in case the ui doesn't want them
|
||||||
|
|
|
@ -185,6 +185,31 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
.Cast<Season>();
|
.Cast<Season>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Episode> GetEpisodes(User user)
|
||||||
|
{
|
||||||
|
var config = user.Configuration;
|
||||||
|
|
||||||
|
var allEpisodes = GetSeasons(user, true, true)
|
||||||
|
.SelectMany(i => i.GetEpisodes(user, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes))
|
||||||
|
.Reverse()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// Specials could appear twice based on above - once in season 0, once in the aired season
|
||||||
|
// This depends on settings for that series
|
||||||
|
// When this happens, remove the duplicate from season 0
|
||||||
|
var returnList = new List<Episode>();
|
||||||
|
|
||||||
|
foreach (var episode in allEpisodes)
|
||||||
|
{
|
||||||
|
if (!returnList.Contains(episode))
|
||||||
|
{
|
||||||
|
returnList.Insert(0, episode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnList;
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Episode> GetEpisodes(User user, int seasonNumber)
|
public IEnumerable<Episode> GetEpisodes(User user, int seasonNumber)
|
||||||
{
|
{
|
||||||
var config = user.Configuration;
|
var config = user.Configuration;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user