Support removing from nbzget queue

This commit is contained in:
Mark McDowall 2014-12-15 21:56:24 -08:00
parent b13b096e77
commit 427b102900
2 changed files with 23 additions and 9 deletions

View File

@ -192,7 +192,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
public override void RemoveItem(String id) public override void RemoveItem(String id)
{ {
_proxy.RemoveFromHistory(id, Settings); _proxy.RemoveItem(id, Settings);
} }
public override String RetryDownload(String id) public override String RetryDownload(String id)

View File

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
List<NzbgetHistoryItem> GetHistory(NzbgetSettings settings); List<NzbgetHistoryItem> GetHistory(NzbgetSettings settings);
String GetVersion(NzbgetSettings settings); String GetVersion(NzbgetSettings settings);
Dictionary<String, String> GetConfig(NzbgetSettings settings); Dictionary<String, String> GetConfig(NzbgetSettings settings);
void RemoveFromHistory(string id, NzbgetSettings settings); void RemoveItem(string id, NzbgetSettings settings);
void RetryDownload(string id, NzbgetSettings settings); void RetryDownload(string id, NzbgetSettings settings);
} }
@ -97,20 +97,34 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
} }
public void RemoveFromHistory(string id, NzbgetSettings settings) public void RemoveItem(string id, NzbgetSettings settings)
{ {
var queue = GetQueue(settings);
var history = GetHistory(settings); var history = GetHistory(settings);
var item = history.SingleOrDefault(h => h.Parameters.Any(p => p.Name == "drone" && id == (p.Value as string)));
if (item == null) var queueItem = queue.SingleOrDefault(h => h.Parameters.Any(p => p.Name == "drone" && id == (p.Value as string)));
var historyItem = history.SingleOrDefault(h => h.Parameters.Any(p => p.Name == "drone" && id == (p.Value as string)));
if (queueItem != null)
{ {
_logger.Warn("Unable to remove item from nzbget's history, Unknown ID: {0}", id); if (!EditQueue("GroupFinalDelete", 0, "", queueItem.NzbId, settings))
return; {
_logger.Warn("Failed to remove item from nzbget queue, {0} [{1}]", queueItem.NzbName, queueItem.NzbId);
}
} }
if (!EditQueue("HistoryDelete", 0, "", item.Id, settings)) else if (historyItem != null)
{ {
_logger.Warn("Failed to remove item from nzbget history, {0} [{1}]", item.Name, item.Id); if (!EditQueue("HistoryDelete", 0, "", historyItem.Id, settings))
{
_logger.Warn("Failed to remove item from nzbget history, {0} [{1}]", historyItem.Name, historyItem.Id);
}
}
else
{
_logger.Warn("Unable to remove item from nzbget, Unknown ID: {0}", id);
return;
} }
} }