fix(matching): Normalize dots to spaces for SAB/Sonarr matching
Some checks failed
Some checks failed
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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user