mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
parent
b97e8d5cf7
commit
a834da3990
8 changed files with 224 additions and 1 deletions
|
@ -327,5 +327,58 @@ namespace PlexRequests.Api
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public SonarrSeasonSearchResult SearchForSeason(int seriesId, int seasonNumber, string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new RestRequest { Resource = "/api/Command", Method = Method.POST };
|
||||
request.AddHeader("X-Api-Key", apiKey);
|
||||
|
||||
var body = new SonarrSearchCommand
|
||||
{
|
||||
name = "SeasonSearch",
|
||||
seriesId = seriesId,
|
||||
seasonNumber = seasonNumber
|
||||
};
|
||||
request.AddJsonBody(body);
|
||||
|
||||
try
|
||||
{
|
||||
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) =>
|
||||
Log.Error(exception, "Exception when calling SearchForSeason for Sonarr, Retrying {0}", timespan));
|
||||
|
||||
return policy.Execute(() => Api.ExecuteJson<SonarrSeasonSearchResult>(request, baseUrl));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e, "There has been an API exception when put the Sonarr SearchForSeason");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public SonarrSeriesSearchResult SearchForSeries(int seriesId, string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new RestRequest { Resource = "/api/Command", Method = Method.POST };
|
||||
request.AddHeader("X-Api-Key", apiKey);
|
||||
|
||||
var body = new SonarrSearchCommand
|
||||
{
|
||||
name = "SeriesSearch",
|
||||
seriesId = seriesId
|
||||
};
|
||||
request.AddJsonBody(body);
|
||||
|
||||
try
|
||||
{
|
||||
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) =>
|
||||
Log.Error(exception, "Exception when calling SearchForSeries for Sonarr, Retrying {0}", timespan));
|
||||
|
||||
return policy.Execute(() => Api.ExecuteJson<SonarrSeriesSearchResult>(request, baseUrl));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e, "There has been an API exception when put the Sonarr SearchForSeries");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue