diff --git a/src/Sonarr.Api.V3/History/HistoryController.cs b/src/Sonarr.Api.V3/History/HistoryController.cs index 58f0bc28c..cb6075676 100644 --- a/src/Sonarr.Api.V3/History/HistoryController.cs +++ b/src/Sonarr.Api.V3/History/HistoryController.cs @@ -7,6 +7,7 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.History; +using NzbDrone.Core.Tv; using Sonarr.Api.V3.Episodes; using Sonarr.Api.V3.Series; using Sonarr.Http; @@ -21,16 +22,19 @@ public class HistoryController : Controller private readonly ICustomFormatCalculationService _formatCalculator; private readonly IUpgradableSpecification _upgradableSpecification; private readonly IFailedDownloadService _failedDownloadService; + private readonly ISeriesService _seriesService; public HistoryController(IHistoryService historyService, ICustomFormatCalculationService formatCalculator, IUpgradableSpecification upgradableSpecification, - IFailedDownloadService failedDownloadService) + IFailedDownloadService failedDownloadService, + ISeriesService seriesService) { _historyService = historyService; _formatCalculator = formatCalculator; _upgradableSpecification = upgradableSpecification; _failedDownloadService = failedDownloadService; + _seriesService = seriesService; } protected HistoryResource MapToResource(EpisodeHistory model, bool includeSeries, bool includeEpisode) @@ -98,12 +102,24 @@ public List GetHistorySince(DateTime date, EpisodeHistoryEventT [Produces("application/json")] public List GetSeriesHistory(int seriesId, int? seasonNumber, EpisodeHistoryEventType? eventType = null, bool includeSeries = false, bool includeEpisode = false) { + var series = _seriesService.GetSeries(seriesId); + if (seasonNumber.HasValue) { - return _historyService.GetBySeason(seriesId, seasonNumber.Value, eventType).Select(h => MapToResource(h, includeSeries, includeEpisode)).ToList(); + return _historyService.GetBySeason(seriesId, seasonNumber.Value, eventType).Select(h => + { + h.Series = series; + + return MapToResource(h, includeSeries, includeEpisode); + }).ToList(); } - return _historyService.GetBySeries(seriesId, eventType).Select(h => MapToResource(h, includeSeries, includeEpisode)).ToList(); + return _historyService.GetBySeries(seriesId, eventType).Select(h => + { + h.Series = series; + + return MapToResource(h, includeSeries, includeEpisode); + }).ToList(); } [HttpPost("failed/{id}")]