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) {