|
|
|
@ -31,6 +31,7 @@ using System;
|
|
|
|
|
using NLog;
|
|
|
|
|
using PlexRequests.Api.Interfaces;
|
|
|
|
|
using PlexRequests.Api.Models.SickRage;
|
|
|
|
|
using PlexRequests.Helpers;
|
|
|
|
|
using RestSharp;
|
|
|
|
|
|
|
|
|
|
namespace PlexRequests.Api
|
|
|
|
@ -47,13 +48,13 @@ namespace PlexRequests.Api
|
|
|
|
|
private ApiRequest Api { get; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SickRageTvAdd AddSeries(int tvdbId, bool latest, string quality, string apiKey,
|
|
|
|
|
public SickRageTvAdd AddSeries(int tvdbId, bool latest, int[] seasons, string quality, string apiKey,
|
|
|
|
|
Uri baseUrl)
|
|
|
|
|
{
|
|
|
|
|
string status;
|
|
|
|
|
var futureStatus = SickRageStatus.Wanted;
|
|
|
|
|
|
|
|
|
|
status = latest ? SickRageStatus.Skipped : SickRageStatus.Wanted;
|
|
|
|
|
status = latest || seasons.Length > 0 ? SickRageStatus.Skipped : SickRageStatus.Wanted;
|
|
|
|
|
|
|
|
|
|
var request = new RestRequest
|
|
|
|
|
{
|
|
|
|
@ -71,6 +72,17 @@ namespace PlexRequests.Api
|
|
|
|
|
|
|
|
|
|
var obj = Api.Execute<SickRageTvAdd>(request, baseUrl);
|
|
|
|
|
|
|
|
|
|
if (!latest && seasons.Length > 0 && obj.result != "failure")
|
|
|
|
|
{
|
|
|
|
|
//handle the seasons requested
|
|
|
|
|
foreach (int s in seasons)
|
|
|
|
|
{
|
|
|
|
|
var result = AddSeason(tvdbId, s, apiKey, baseUrl);
|
|
|
|
|
Log.Trace("SickRage adding season results: ");
|
|
|
|
|
Log.Trace(result.DumpJson());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -87,5 +99,22 @@ namespace PlexRequests.Api
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SickRageTvAdd AddSeason(int tvdbId, int season, string apiKey, Uri baseUrl)
|
|
|
|
|
{
|
|
|
|
|
var request = new RestRequest
|
|
|
|
|
{
|
|
|
|
|
Resource = "/api/{apiKey}/?cmd=episode.setstatus",
|
|
|
|
|
Method = Method.GET
|
|
|
|
|
};
|
|
|
|
|
request.AddUrlSegment("apiKey", apiKey);
|
|
|
|
|
request.AddQueryParameter("tvdbid", tvdbId.ToString());
|
|
|
|
|
request.AddQueryParameter("season", season.ToString());
|
|
|
|
|
request.AddQueryParameter("status", SickRageStatus.Wanted);
|
|
|
|
|
|
|
|
|
|
var obj = Api.Execute<SickRageTvAdd>(request, baseUrl);
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|