fix: les series sans torrents sont bien organiser si importé manuellement
This commit is contained in:
1 parent
66b0313ae9
commit
89f225b980
1 file changed
+16
-3
+16
-3
@@ -103,10 +103,10 @@ export async function scanMediaPath(
|
|||||||
if (ep.nfo_filename) idx(ep.nfo_filename, hash, ep.nfo_filename)
|
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
|
// 2. original_filename, nfo_filename et formatted_name — indexés même si paths est vide
|
||||||
// (pour les séries sans torrent importées manuellement)
|
|
||||||
const fallbackHash = ep.paths?.[0]?.infohash?.toLowerCase() ?? 'manual'
|
const fallbackHash = ep.paths?.[0]?.infohash?.toLowerCase() ?? 'manual'
|
||||||
if (ep.original_filename) idx(ep.original_filename, fallbackHash, ep.original_filename)
|
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()) {
|
if (ep.formatted_name?.trim()) {
|
||||||
const fmtBase = ep.formatted_name.replace(/[<>:"/\\|?*]/g, '').trim()
|
const fmtBase = ep.formatted_name.replace(/[<>:"/\\|?*]/g, '').trim()
|
||||||
idx(fmtBase, fallbackHash, fmtBase)
|
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)) {
|
} else if (entry.isFile() && /\.(mkv|mp4|avi|m4v|mov|wmv)$/i.test(entry.name)) {
|
||||||
result.found++
|
result.found++
|
||||||
const nameWithoutExt = entry.name.replace(/\.[^.]+$/, '')
|
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) {
|
if (!match) {
|
||||||
noMatch++
|
noMatch++
|
||||||
const prefix = nameWithoutExt.slice(0, 20).toLowerCase()
|
const prefix = nameWithoutExt.slice(0, 20).toLowerCase()
|
||||||
|
|||||||
Reference in new issue
Block a user