mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 02:22:31 +01:00
New: Use the ID returned from SABnzbd (0.7.20) during retry
This commit is contained in:
parent
6467167046
commit
935b9e5f4e
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NzbDrone.Common
|
namespace NzbDrone.Common.Extensions
|
||||||
{
|
{
|
||||||
public static class TryParseExtensions
|
public static class TryParseExtensions
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Download.Clients.Sabnzbd.Responses
|
||||||
|
{
|
||||||
|
public class SabnzbdRetryResponse
|
||||||
|
{
|
||||||
|
public bool Status { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(PropertyName = "nzo_id")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -223,7 +223,12 @@ public override String RetryDownload(String id)
|
|||||||
var otherItemsWithSameTitle = currentHistory.Where(h => h.Title == currentHistoryItem.Title &&
|
var otherItemsWithSameTitle = currentHistory.Where(h => h.Title == currentHistoryItem.Title &&
|
||||||
h.DownloadClientId != currentHistoryItem.DownloadClientId).ToList();
|
h.DownloadClientId != currentHistoryItem.DownloadClientId).ToList();
|
||||||
|
|
||||||
_proxy.RetryDownload(id, Settings);
|
var newId = _proxy.RetryDownload(id, Settings);
|
||||||
|
|
||||||
|
if (newId.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
return newId;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common;
|
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
using NzbDrone.Core.Rest;
|
using NzbDrone.Core.Rest;
|
||||||
@ -22,7 +18,7 @@ public interface ISabnzbdProxy
|
|||||||
SabnzbdConfig GetConfig(SabnzbdSettings settings);
|
SabnzbdConfig GetConfig(SabnzbdSettings settings);
|
||||||
SabnzbdQueue GetQueue(int start, int limit, SabnzbdSettings settings);
|
SabnzbdQueue GetQueue(int start, int limit, SabnzbdSettings settings);
|
||||||
SabnzbdHistory GetHistory(int start, int limit, SabnzbdSettings settings);
|
SabnzbdHistory GetHistory(int start, int limit, SabnzbdSettings settings);
|
||||||
void RetryDownload(string id, SabnzbdSettings settings);
|
string RetryDownload(string id, SabnzbdSettings settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SabnzbdProxy : ISabnzbdProxy
|
public class SabnzbdProxy : ISabnzbdProxy
|
||||||
@ -114,12 +110,20 @@ public SabnzbdHistory GetHistory(int start, int limit, SabnzbdSettings settings)
|
|||||||
return Json.Deserialize<SabnzbdHistory>(JObject.Parse(response).SelectToken("history").ToString());
|
return Json.Deserialize<SabnzbdHistory>(JObject.Parse(response).SelectToken("history").ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RetryDownload(string id, SabnzbdSettings settings)
|
public string RetryDownload(string id, SabnzbdSettings settings)
|
||||||
{
|
{
|
||||||
var request = new RestRequest();
|
var request = new RestRequest();
|
||||||
var action = String.Format("mode=retry&value={0}", id);
|
var action = String.Format("mode=retry&value={0}", id);
|
||||||
|
|
||||||
ProcessRequest(request, action, settings);
|
SabnzbdRetryResponse response;
|
||||||
|
|
||||||
|
if (!Json.TryDeserialize<SabnzbdRetryResponse>(ProcessRequest(request, action, settings), out response))
|
||||||
|
{
|
||||||
|
response = new SabnzbdRetryResponse();
|
||||||
|
response.Status = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IRestClient BuildClient(string action, SabnzbdSettings settings)
|
private IRestClient BuildClient(string action, SabnzbdSettings settings)
|
||||||
|
Loading…
Reference in New Issue
Block a user