Work around the sonarr bug #254

pull/470/head
tidusjar 8 years ago
parent 5411225fa0
commit 5024178724

@ -46,6 +46,6 @@ namespace PlexRequests.Api.Interfaces
SonarrEpisode GetEpisode(string episodeId, string apiKey, Uri baseUrl);
SonarrEpisode UpdateEpisode(SonarrEpisode episodeInfo, string apiKey, Uri baseUrl);
SonarrAddEpisodeResult SearchForEpisodes(int[] episodeIds, string apiKey, Uri baseUrl);
Series UpdateSeries(Series series, string apiKey, Uri baseUrl);
}
}

@ -300,5 +300,26 @@ namespace PlexRequests.Api
return null;
}
}
public Series UpdateSeries(Series series, string apiKey, Uri baseUrl)
{
var request = new RestRequest { Resource = "/api/Series", Method = Method.PUT };
request.AddHeader("X-Api-Key", apiKey);
request.AddJsonBody(series);
try
{
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) =>
Log.Error(exception, "Exception when calling UpdateSeries for Sonarr, Retrying {0}", timespan));
return policy.Execute(() => Api.ExecuteJson<Series>(request, baseUrl));
}
catch (Exception e)
{
Log.Error(e, "There has been an API exception when put the Sonarr UpdateSeries");
return null;
}
}
}
}

@ -108,6 +108,9 @@ namespace PlexRequests.UI.Helpers
}
}
sw.Stop();
// Update the series, Since we cannot add as unmonitoed due to the following bug: https://github.com/Sonarr/Sonarr/issues/1404
SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri);
}
// We now have the series in Sonarr

Loading…
Cancel
Save