mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Updating SickRage api to verify Season List is up to date
This commit is contained in:
parent
cccb71b605
commit
6921e3aa85
7 changed files with 62 additions and 29 deletions
|
@ -74,17 +74,16 @@ namespace PlexRequests.Api
|
|||
|
||||
var obj = Api.Execute<SickRageTvAdd>(request, baseUrl);
|
||||
|
||||
|
||||
if (obj.result != "failure")
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
// Check to see if it's been added yet.
|
||||
var showInfo = new SickRageShowInformation { message = "Show not found" };
|
||||
while (showInfo.message.Equals("Show not found", StringComparison.CurrentCultureIgnoreCase))
|
||||
var seasonList = new SickRageSeasonList();
|
||||
while (seasonList.data.Length < seasonCount)
|
||||
{
|
||||
showInfo = CheckShowHasBeenAdded(tvdbId, apiKey, baseUrl);
|
||||
seasonList = VerifyShowHasLoaded(tvdbId, apiKey, baseUrl);
|
||||
if (sw.ElapsedMilliseconds > 30000) // Break out after 30 seconds, it's not going to get added
|
||||
{
|
||||
Log.Warn("Couldn't find out if the show had been added after 10 seconds. I doubt we can change the status to wanted.");
|
||||
|
@ -94,7 +93,6 @@ namespace PlexRequests.Api
|
|||
sw.Stop();
|
||||
}
|
||||
|
||||
|
||||
if (seasons.Length > 0)
|
||||
{
|
||||
//handle the seasons requested
|
||||
|
@ -123,6 +121,21 @@ namespace PlexRequests.Api
|
|||
return obj;
|
||||
}
|
||||
|
||||
public SickRageSeasonList VerifyShowHasLoaded(int tvdbId, string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new RestRequest
|
||||
{
|
||||
Resource = "/api/{apiKey}/?cmd=show.seasonlist",
|
||||
Method = Method.GET
|
||||
};
|
||||
request.AddUrlSegment("apiKey", apiKey);
|
||||
request.AddQueryParameter("tvdbid", tvdbId.ToString());
|
||||
|
||||
var obj = Api.ExecuteJson<SickRageSeasonList>(request, baseUrl);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public async Task<SickRageTvAdd> AddSeason(int tvdbId, int season, string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new RestRequest
|
||||
|
@ -140,19 +153,19 @@ namespace PlexRequests.Api
|
|||
}
|
||||
|
||||
|
||||
public SickRageShowInformation CheckShowHasBeenAdded(int tvdbId, string apiKey, Uri baseUrl)
|
||||
{
|
||||
var request = new RestRequest
|
||||
{
|
||||
Resource = "/api/{apiKey}/?cmd=show",
|
||||
Method = Method.GET
|
||||
};
|
||||
request.AddUrlSegment("apiKey", apiKey);
|
||||
request.AddQueryParameter("tvdbid", tvdbId.ToString());
|
||||
//public SickRageShowInformation CheckShowHasBeenAdded(int tvdbId, string apiKey, Uri baseUrl)
|
||||
//{
|
||||
// var request = new RestRequest
|
||||
// {
|
||||
// Resource = "/api/{apiKey}/?cmd=show",
|
||||
// Method = Method.GET
|
||||
// };
|
||||
// request.AddUrlSegment("apiKey", apiKey);
|
||||
// request.AddQueryParameter("tvdbid", tvdbId.ToString());
|
||||
|
||||
var obj = Api.Execute<SickRageShowInformation>(request, baseUrl);
|
||||
// var obj = Api.Execute<SickRageShowInformation>(request, baseUrl);
|
||||
|
||||
return obj;
|
||||
}
|
||||
// return obj;
|
||||
//}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue