From 42f9992af066616c17281006b3fa6f4b60a12ac7 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 22 Feb 2015 19:55:00 +0100 Subject: [PATCH] Fixed: CDH can now remove items after import from NzbGet it didn't grab itself. --- .../Download/Clients/Nzbget/NzbgetProxy.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs index 0bee88ab9..02e95b3d0 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs @@ -102,9 +102,22 @@ public void RemoveItem(string id, NzbgetSettings settings) var queue = GetQueue(settings); var history = GetHistory(settings); - 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))); + int nzbId; + NzbgetQueueItem queueItem; + NzbgetHistoryItem historyItem; + if (id.Length < 10 && int.TryParse(id, out nzbId)) + { + // Download wasn't grabbed by Sonarr, so the id is the NzbId reported by nzbget. + queueItem = queue.SingleOrDefault(h => h.NzbId == nzbId); + historyItem = history.SingleOrDefault(h => h.Id == nzbId); + } + else + { + queueItem = queue.SingleOrDefault(h => h.Parameters.Any(p => p.Name == "drone" && id == (p.Value as string))); + historyItem = history.SingleOrDefault(h => h.Parameters.Any(p => p.Name == "drone" && id == (p.Value as string))); + } + if (queueItem != null) { if (!EditQueue("GroupFinalDelete", 0, "", queueItem.NzbId, settings))