From 235a866ec84023b073cacf537294f9ae722cb455 Mon Sep 17 00:00:00 2001 From: Gronod Date: Tue, 19 May 2026 22:06:38 +0100 Subject: [PATCH] fix(matching): Check Sonarr/Radarr history for SAB matches SAB items often persist after Sonarr has processed them. Previously only checked the active queue, now also checks history records so completed downloads still appear. --- server/routes/dashboard.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/server/routes/dashboard.js b/server/routes/dashboard.js index 877b46b..4131ab3 100644 --- a/server/routes/dashboard.js +++ b/server/routes/dashboard.js @@ -1016,20 +1016,41 @@ router.get('/stream', requireAuth, async (req, res) => { // Normalize SAB name (dots to spaces) for better matching const nzbNameNormalized = nzbNameLower.replace(/\./g, ' '); - const sonarrMatch = sonarrQueue.data.records.find(r => { + // Check Sonarr/Radarr QUEUE (active downloads) + let sonarrMatch = sonarrQueue.data.records.find(r => { const rTitle = (r.title || r.sourceTitle || '').toLowerCase(); return rTitle && ( rTitle.includes(nzbNameLower) || nzbNameLower.includes(rTitle) || rTitle.includes(nzbNameNormalized) || nzbNameNormalized.includes(rTitle) ); }); - const radarrMatch = radarrQueue.data.records.find(r => { + let radarrMatch = radarrQueue.data.records.find(r => { const rTitle = (r.title || r.sourceTitle || '').toLowerCase(); return rTitle && ( rTitle.includes(nzbNameLower) || nzbNameLower.includes(rTitle) || rTitle.includes(nzbNameNormalized) || nzbNameNormalized.includes(rTitle) ); }); + + // Also check HISTORY (completed downloads) if no queue match + if (!sonarrMatch) { + sonarrMatch = sonarrHistory.data.records.find(r => { + const rTitle = (r.title || r.sourceTitle || '').toLowerCase(); + return rTitle && ( + rTitle.includes(nzbNameLower) || nzbNameLower.includes(rTitle) || + rTitle.includes(nzbNameNormalized) || nzbNameNormalized.includes(rTitle) + ); + }); + } + if (!radarrMatch) { + radarrMatch = radarrHistory.data.records.find(r => { + const rTitle = (r.title || r.sourceTitle || '').toLowerCase(); + return rTitle && ( + rTitle.includes(nzbNameLower) || nzbNameLower.includes(rTitle) || + rTitle.includes(nzbNameNormalized) || nzbNameNormalized.includes(rTitle) + ); + }); + } // Debug first 5 items - show matches and non-matches if (sabSlotsChecked <= 5) { if (sonarrMatch) {