diff --git a/PlexRequests.Api/SickrageApi.cs b/PlexRequests.Api/SickrageApi.cs index 4f52d751a..9d41b8419 100644 --- a/PlexRequests.Api/SickrageApi.cs +++ b/PlexRequests.Api/SickrageApi.cs @@ -79,11 +79,13 @@ namespace PlexRequests.Api var sw = new Stopwatch(); sw.Start(); - // Check to see if it's been added yet. + var seasonIncrement = 0; var seasonList = new SickRageSeasonList(); - while (seasonList.data.Length < seasonCount) + while (seasonIncrement < seasonCount) { seasonList = VerifyShowHasLoaded(tvdbId, apiKey, baseUrl); + seasonIncrement = seasonList.data?.Length ?? 0; + 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."); @@ -92,7 +94,6 @@ namespace PlexRequests.Api } sw.Stop(); } - if (seasons.Length > 0) { //handle the seasons requested @@ -151,21 +152,5 @@ namespace PlexRequests.Api await Task.Run(() => Thread.Sleep(2000)); return await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); } - - - //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(request, baseUrl); - - // return obj; - //} } } \ No newline at end of file