1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

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 @@ public override IEnumerable<DownloadClientItem> GetItems()
public override void RemoveItem(String id)
{
_proxy.RemoveFromHistory(id, Settings);
_proxy.RemoveItem(id, Settings);
}
public override String RetryDownload(String id)

View File

@ -16,7 +16,7 @@ public interface INzbgetProxy
List<NzbgetHistoryItem> GetHistory(NzbgetSettings settings);
String GetVersion(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);
}
@ -97,20 +97,34 @@ public Dictionary<String, String> GetConfig(NzbgetSettings settings)
}
public void RemoveFromHistory(string id, NzbgetSettings settings)
public void RemoveItem(string id, NzbgetSettings settings)
{
var queue = GetQueue(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);
return;
if (!EditQueue("GroupFinalDelete", 0, "", queueItem.NzbId, settings))
{
_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;
}
}