mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
Merge branch 'newdev' into SickRageAsyncIssue
This commit is contained in:
commit
5cd2651e1b
7 changed files with 53 additions and 35 deletions
|
@ -64,7 +64,9 @@
|
||||||
<Compile Include="Plex\PlexStatus.cs" />
|
<Compile Include="Plex\PlexStatus.cs" />
|
||||||
<Compile Include="Plex\PlexUserRequest.cs" />
|
<Compile Include="Plex\PlexUserRequest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="SickRage\SickRageBase.cs" />
|
||||||
<Compile Include="SickRage\SickRagePing.cs" />
|
<Compile Include="SickRage\SickRagePing.cs" />
|
||||||
|
<Compile Include="SickRage\SickRageSeasonList.cs" />
|
||||||
<Compile Include="SickRage\SickRageShowInformation.cs" />
|
<Compile Include="SickRage\SickRageShowInformation.cs" />
|
||||||
<Compile Include="SickRage\SickRageStatus.cs" />
|
<Compile Include="SickRage\SickRageStatus.cs" />
|
||||||
<Compile Include="SickRage\SickRageTvAdd.cs" />
|
<Compile Include="SickRage\SickRageTvAdd.cs" />
|
||||||
|
|
15
PlexRequests.Api.Models/SickRage/SickRageBase.cs
Normal file
15
PlexRequests.Api.Models/SickRage/SickRageBase.cs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlexRequests.Api.Models.SickRage
|
||||||
|
{
|
||||||
|
public class SickRageBase<T>
|
||||||
|
{
|
||||||
|
public T data { get; set; }
|
||||||
|
public string message { get; set; }
|
||||||
|
public string result { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,10 +31,7 @@ namespace PlexRequests.Api.Models.SickRage
|
||||||
public int pid { get; set; }
|
public int pid { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SickRagePing
|
public class SickRagePing : SickRageBase<SickRagePingData>
|
||||||
{
|
{
|
||||||
public SickRagePingData data { get; set; }
|
|
||||||
public string message { get; set; }
|
|
||||||
public string result { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
12
PlexRequests.Api.Models/SickRage/SickRageSeasonList.cs
Normal file
12
PlexRequests.Api.Models/SickRage/SickRageSeasonList.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlexRequests.Api.Models.SickRage
|
||||||
|
{
|
||||||
|
public class SickRageSeasonList : SickRageBase<int[]>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,11 +75,8 @@ namespace PlexRequests.Api.Models.SickRage
|
||||||
public int tvdbid { get; set; }
|
public int tvdbid { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SickRageShowInformation
|
public class SickRageShowInformation : SickRageBase<Data>
|
||||||
{
|
{
|
||||||
public Data data { get; set; }
|
|
||||||
public string message { get; set; }
|
|
||||||
public string result { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,11 +31,8 @@ namespace PlexRequests.Api.Models.SickRage
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SickRageTvAdd
|
public class SickRageTvAdd : SickRageBase<SickRageTvAddData>
|
||||||
{
|
{
|
||||||
public SickRageTvAddData data { get; set; }
|
|
||||||
public string message { get; set; }
|
|
||||||
public string result { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -74,17 +74,18 @@ namespace PlexRequests.Api
|
||||||
|
|
||||||
var obj = Api.Execute<SickRageTvAdd>(request, baseUrl);
|
var obj = Api.Execute<SickRageTvAdd>(request, baseUrl);
|
||||||
|
|
||||||
|
|
||||||
if (obj.result != "failure")
|
if (obj.result != "failure")
|
||||||
{
|
{
|
||||||
var sw = new Stopwatch();
|
var sw = new Stopwatch();
|
||||||
sw.Start();
|
sw.Start();
|
||||||
|
|
||||||
// Check to see if it's been added yet.
|
var seasonIncrement = 0;
|
||||||
var showInfo = new SickRageShowInformation { message = "Show not found" };
|
var seasonList = new SickRageSeasonList();
|
||||||
while (showInfo.message.Equals("Show not found", StringComparison.CurrentCultureIgnoreCase))
|
while (seasonIncrement < seasonCount)
|
||||||
{
|
{
|
||||||
showInfo = CheckShowHasBeenAdded(tvdbId, apiKey, baseUrl);
|
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
|
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.");
|
Log.Warn("Couldn't find out if the show had been added after 10 seconds. I doubt we can change the status to wanted.");
|
||||||
|
@ -93,8 +94,6 @@ namespace PlexRequests.Api
|
||||||
}
|
}
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (seasons.Length > 0)
|
if (seasons.Length > 0)
|
||||||
{
|
{
|
||||||
//handle the seasons requested
|
//handle the seasons requested
|
||||||
|
@ -123,6 +122,21 @@ namespace PlexRequests.Api
|
||||||
return obj;
|
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)
|
public async Task<SickRageTvAdd> AddSeason(int tvdbId, int season, string apiKey, Uri baseUrl)
|
||||||
{
|
{
|
||||||
var request = new RestRequest
|
var request = new RestRequest
|
||||||
|
@ -138,21 +152,5 @@ namespace PlexRequests.Api
|
||||||
await Task.Run(() => Thread.Sleep(2000));
|
await Task.Run(() => Thread.Sleep(2000));
|
||||||
return await Task.Run(() => Api.Execute<SickRageTvAdd>(request, baseUrl)).ConfigureAwait(false);
|
return await Task.Run(() => Api.Execute<SickRageTvAdd>(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<SickRageShowInformation>(request, baseUrl);
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue