Skip to content

Commit

Permalink
fix(sonarr): Fixed where requesting all seasons would only mark the l…
Browse files Browse the repository at this point in the history
…atest as monitored #4496
  • Loading branch information
tidusjar committed Feb 5, 2022
1 parent 1d488e7 commit cfb85c2
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Ombi.Core/Senders/TvSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public async Task<NewSeries> SendToSonarr(ChildRequests model, SonarrSettings s)
languageProfileId = languageProfile;
}
}

try
{
// Does the series actually exist?
Expand Down Expand Up @@ -358,7 +358,7 @@ private async Task SendToSonarr(ChildRequests model, SonarrSeries result, Sonarr
}
}
var sonarrEpisodeList = sonarrEpList.Where(x => x.seasonNumber == season.SeasonNumber).ToList();
var sonarrEpCount = sonarrEpisodeList.Count;
var sonarrEpCount = sonarrEpisodeList.Count;
var ourRequestCount = season.Episodes.Count;

var ourEpisodes = season.Episodes.Select(x => x.EpisodeNumber).ToList();
Expand All @@ -374,17 +374,12 @@ private async Task SendToSonarr(ChildRequests model, SonarrSeries result, Sonarr
if (sonarrEpCount == ourRequestCount /*|| !missingEpisodes.Any()*/)
{
// We have the same amount of requests as all of the episodes in the season.
existingSeason.monitored = true;
seriesChanges = true;

if (!existingSeason.monitored)
{
existingSeason.monitored = true;
seriesChanges = true;
}
// Now update the episodes that need updating
foreach (var epToUpdate in episodesToUpdate.Where(x => x.seasonNumber == season.SeasonNumber))
{
await SonarrApi.UpdateEpisode(epToUpdate, s.ApiKey, s.FullUri);
}
// We do not need to update the episodes as marking the season as monitored will mark the episodes as monitored.
var seasonToUpdate = result.seasons.FirstOrDefault(x => x.seasonNumber == season.SeasonNumber);
seasonToUpdate.monitored = true; // Update by ref
}
else
{
Expand Down Expand Up @@ -442,7 +437,6 @@ private static List<Season> GetSeasonsToCreate(ChildRequests model)
var seasonsToUpdate = new List<Season>();
for (var i = 0; i < model.ParentRequest.TotalSeasons + 1; i++)
{
var index = i;
var sea = new Season
{
seasonNumber = i,
Expand Down

0 comments on commit cfb85c2

Please # to comment.