mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
So... This sickrage thing should work now
This commit is contained in:
parent
6ad6dd4a74
commit
152189213d
5 changed files with 29 additions and 9 deletions
|
@ -11,7 +11,7 @@ namespace Ombi.Api.SickRage
|
||||||
Task<SickRagePing> Ping(string apiKey, string baseUrl);
|
Task<SickRagePing> Ping(string apiKey, string baseUrl);
|
||||||
Task<SickRageSeasonList> VerifyShowHasLoaded(int tvdbId, string apiKey, string baseUrl);
|
Task<SickRageSeasonList> VerifyShowHasLoaded(int tvdbId, string apiKey, string baseUrl);
|
||||||
Task<SickRageShowInformation> GetShow(int tvdbid, string apikey, string baseUrl);
|
Task<SickRageShowInformation> GetShow(int tvdbid, string apikey, string baseUrl);
|
||||||
Task<SickRageEpisodeStatus> SetEpisodeStatus(string apiKey, string baseUrl, int tvdbid, string status,
|
Task<SickRageEpisodeSetStatus> SetEpisodeStatus(string apiKey, string baseUrl, int tvdbid, string status,
|
||||||
int season, int episode = -1);
|
int season, int episode = -1);
|
||||||
Task<SickRageEpisodes> GetEpisodesForSeason(int tvdbid, int season, string apikey, string baseUrl);
|
Task<SickRageEpisodes> GetEpisodesForSeason(int tvdbid, int season, string apikey, string baseUrl);
|
||||||
Task<SeasonList> GetSeasonList(int tvdbId, string apikey, string baseurl);
|
Task<SeasonList> GetSeasonList(int tvdbId, string apikey, string baseurl);
|
||||||
|
|
|
@ -7,6 +7,13 @@
|
||||||
public string result { get; set; }
|
public string result { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SickRageEpisodeSetStatus
|
||||||
|
{
|
||||||
|
public Data data { get; set; }
|
||||||
|
public string message { get; set; }
|
||||||
|
public string result { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class Data
|
public class Data
|
||||||
{
|
{
|
||||||
public int episode { get; set; }
|
public int episode { get; set; }
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
{
|
{
|
||||||
public const string Wanted = "wanted";
|
public const string Wanted = "wanted";
|
||||||
public const string Skipped = "skipped";
|
public const string Skipped = "skipped";
|
||||||
public const string Ignored = "Ignored";
|
public const string Ignored = "ignored";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,6 +32,10 @@ namespace Ombi.Api.SickRage
|
||||||
request.AddQueryString("tvdbid", tvdbId.ToString());
|
request.AddQueryString("tvdbid", tvdbId.ToString());
|
||||||
request.AddQueryString("status", status);
|
request.AddQueryString("status", status);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(quality))
|
||||||
|
{
|
||||||
|
quality = "default";
|
||||||
|
}
|
||||||
if (!quality.Equals("default", StringComparison.CurrentCultureIgnoreCase))
|
if (!quality.Equals("default", StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
request.AddQueryString("initial", quality);
|
request.AddQueryString("initial", quality);
|
||||||
|
@ -88,7 +92,7 @@ namespace Ombi.Api.SickRage
|
||||||
/// The episode number is optional, if not supplied it will set the whole season as the status passed in
|
/// The episode number is optional, if not supplied it will set the whole season as the status passed in
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<SickRageEpisodeStatus> SetEpisodeStatus(string apiKey, string baseUrl, int tvdbid, string status, int season, int episode = -1)
|
public async Task<SickRageEpisodeSetStatus> SetEpisodeStatus(string apiKey, string baseUrl, int tvdbid, string status, int season, int episode = -1)
|
||||||
{
|
{
|
||||||
var request = new Request($"/api/{apiKey}/?cmd=episode.setstatus", baseUrl, HttpMethod.Get);
|
var request = new Request($"/api/{apiKey}/?cmd=episode.setstatus", baseUrl, HttpMethod.Get);
|
||||||
request.AddQueryString("tvdbid", tvdbid.ToString());
|
request.AddQueryString("tvdbid", tvdbid.ToString());
|
||||||
|
@ -100,7 +104,7 @@ namespace Ombi.Api.SickRage
|
||||||
request.AddQueryString("episode", episode.ToString());
|
request.AddQueryString("episode", episode.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return await _api.Request<SickRageEpisodeStatus>(request);
|
return await _api.Request<SickRageEpisodeSetStatus>(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SeasonList> GetSeasonList(int tvdbId, string apikey, string baseurl)
|
public async Task<SeasonList> GetSeasonList(int tvdbId, string apikey, string baseurl)
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace Ombi.Core.Senders
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(string.IsNullOrEmpty(s.ApiKey))
|
if (string.IsNullOrEmpty(s.ApiKey))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -272,13 +272,16 @@ namespace Ombi.Core.Senders
|
||||||
qualityId = settings.QualityProfile;
|
qualityId = settings.QualityProfile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qualityId = settings.QualityProfile;
|
||||||
|
}
|
||||||
// Check if the show exists
|
// Check if the show exists
|
||||||
var existingShow = await SickRageApi.GetShow(tvdbid, settings.ApiKey, settings.FullUri);
|
var existingShow = await SickRageApi.GetShow(tvdbid, settings.ApiKey, settings.FullUri);
|
||||||
|
|
||||||
if (existingShow == null)
|
if (existingShow.message.Equals("Show not found", StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
var addResult = await SickRageApi.AddSeries(model.ParentRequest.TvDbId, SickRageStatus.Wanted,
|
var addResult = await SickRageApi.AddSeries(model.ParentRequest.TvDbId, qualityId, SickRageStatus.Ignored,
|
||||||
qualityId,
|
|
||||||
settings.ApiKey, settings.FullUri);
|
settings.ApiKey, settings.FullUri);
|
||||||
|
|
||||||
Logger.LogDebug("Added the show (tvdbid) {0}. The result is '{2}' : '{3}'", tvdbid, addResult.result, addResult.message);
|
Logger.LogDebug("Added the show (tvdbid) {0}. The result is '{2}' : '{3}'", tvdbid, addResult.result, addResult.message);
|
||||||
|
@ -292,6 +295,12 @@ namespace Ombi.Core.Senders
|
||||||
foreach (var seasonRequests in model.SeasonRequests)
|
foreach (var seasonRequests in model.SeasonRequests)
|
||||||
{
|
{
|
||||||
var srEpisodes = await SickRageApi.GetEpisodesForSeason(tvdbid, seasonRequests.SeasonNumber, settings.ApiKey, settings.FullUri);
|
var srEpisodes = await SickRageApi.GetEpisodesForSeason(tvdbid, seasonRequests.SeasonNumber, settings.ApiKey, settings.FullUri);
|
||||||
|
while (srEpisodes.message.Equals("Show not found", StringComparison.CurrentCultureIgnoreCase) && srEpisodes.data.Count <= 0)
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||||
|
srEpisodes = await SickRageApi.GetEpisodesForSeason(tvdbid, seasonRequests.SeasonNumber, settings.ApiKey, settings.FullUri);
|
||||||
|
}
|
||||||
|
|
||||||
var totalSrEpisodes = srEpisodes.data.Count;
|
var totalSrEpisodes = srEpisodes.data.Count;
|
||||||
|
|
||||||
if (totalSrEpisodes == seasonRequests.Episodes.Count)
|
if (totalSrEpisodes == seasonRequests.Episodes.Count)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue