From 9d0e31ec9a8f7567825ed54c29ebe444bf658efb Mon Sep 17 00:00:00 2001 From: Gronod Date: Tue, 19 May 2026 22:02:55 +0100 Subject: [PATCH] fix(matching): Normalize dots to spaces for SAB/Sonarr matching SAB filenames use dots (dora.the.explorer.s02e08) but Sonarr titles use spaces (Dora the Explorer - S02E08). Now tries matching with both formats to improve match rate. Also logs actual Sonarr titles when no match found for debugging. --- server/routes/dashboard.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/server/routes/dashboard.js b/server/routes/dashboard.js index 9041af1..70efeea 100644 --- a/server/routes/dashboard.js +++ b/server/routes/dashboard.js @@ -1013,13 +1013,22 @@ router.get('/stream', requireAuth, async (req, res) => { const slotState = getSlotStatusAndSpeed(slot); const nzbNameLower = nzbName.toLowerCase(); + // Normalize SAB name (dots to spaces) for better matching + const nzbNameNormalized = nzbNameLower.replace(/\./g, ' '); + const sonarrMatch = sonarrQueue.data.records.find(r => { const rTitle = (r.title || r.sourceTitle || '').toLowerCase(); - return rTitle && (rTitle.includes(nzbNameLower) || nzbNameLower.includes(rTitle)); + return rTitle && ( + rTitle.includes(nzbNameLower) || nzbNameLower.includes(rTitle) || + rTitle.includes(nzbNameNormalized) || nzbNameNormalized.includes(rTitle) + ); }); const radarrMatch = radarrQueue.data.records.find(r => { const rTitle = (r.title || r.sourceTitle || '').toLowerCase(); - return rTitle && (rTitle.includes(nzbNameLower) || nzbNameLower.includes(rTitle)); + 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) { @@ -1029,7 +1038,9 @@ router.get('/stream', requireAuth, async (req, res) => { console.log(`[SSE] ✓ Radarr match: SAB:"${nzbNameLower.substring(0, 50)}" → Radarr:"${(radarrMatch.title || radarrMatch.sourceTitle || '').substring(0, 50)}"`); } else { console.log(`[SSE] ✗ No match for SAB: "${nzbNameLower.substring(0, 60)}"`); - console.log(`[SSE] Sonarr queue has ${sonarrQueue.data.records.length} items`); + // Show actual Sonarr titles to debug matching + const sonarrTitles = sonarrQueue.data.records.slice(0, 5).map(r => (r.title || r.sourceTitle || 'NO_TITLE').substring(0, 50)); + console.log(`[SSE] Sonarr titles: ${sonarrTitles.join(' | ')}`); } } if (sonarrMatch && sonarrMatch.seriesId) {