From 89f225b980c7f560e9b64dd158b7faa549cb97af Mon Sep 17 00:00:00 2001 From: MasutaYunikon Date: Sat, 11 Apr 2026 12:15:35 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20les=20series=20sans=20torrents=20sont=20?= =?UTF-8?q?bien=20organiser=20si=20import=C3=A9=20manuellement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/organize.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/server/organize.ts b/server/organize.ts index f28bf80..d61f820 100644 --- a/server/organize.ts +++ b/server/organize.ts @@ -103,10 +103,10 @@ export async function scanMediaPath( if (ep.nfo_filename) idx(ep.nfo_filename, hash, ep.nfo_filename) } - // 2. original_filename et formatted_name — indexés même si paths est vide - // (pour les séries sans torrent importées manuellement) + // 2. original_filename, nfo_filename et formatted_name — indexés même si paths est vide const fallbackHash = ep.paths?.[0]?.infohash?.toLowerCase() ?? 'manual' if (ep.original_filename) idx(ep.original_filename, fallbackHash, ep.original_filename) + if (ep.nfo_filename) idx(ep.nfo_filename, fallbackHash, ep.nfo_filename) if (ep.formatted_name?.trim()) { const fmtBase = ep.formatted_name.replace(/[<>:"/\\|?*]/g, '').trim() idx(fmtBase, fallbackHash, fmtBase) @@ -136,7 +136,20 @@ export async function scanMediaPath( } else if (entry.isFile() && /\.(mkv|mp4|avi|m4v|mov|wmv)$/i.test(entry.name)) { result.found++ const nameWithoutExt = entry.name.replace(/\.[^.]+$/, '') - const match = filenameIndex.get(nameWithoutExt) + let match = filenameIndex.get(nameWithoutExt) + + // Fallback : chercher si un candidat de l'index est un préfixe du nom du fichier + // ex: index a "Wind Breaker.S01E01.MULTI.1080p" et le fichier est "Wind Breaker.S01E01.MULTI.1080p.x264-FANKAI" + if (!match) { + const lower = nameWithoutExt.toLowerCase() + for (const [key, val] of filenameIndex.entries()) { + if (lower.startsWith(key.toLowerCase() + '.') || lower === key.toLowerCase()) { + match = val + break + } + } + } + if (!match) { noMatch++ const prefix = nameWithoutExt.slice(0, 20).toLowerCase()