fix: le bouton rename n'apparait plus quand on utilise differents torrents entre les épisode
This commit is contained in:
1 parent
2c9bef8883
commit
105cc05bdf
2 files changed
+23
-8
No files matched your search
+22
-6
@@ -139,19 +139,35 @@ router.get('/organized/:serieId', requireAuth, async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
const sd = await readSerieData(serieId)
|
const sd = await readSerieData(serieId)
|
||||||
if (!sd) { res.status(404).json({ error: 'Série introuvable' }); return }
|
if (!sd) { res.status(404).json({ error: 'Série introuvable' }); return }
|
||||||
const organized = loadOrganizedJson()
|
const organized = loadOrganizedJson()
|
||||||
|
const { nfoSupport } = readSettings()
|
||||||
const result: Record<string, any> = {}
|
const result: Record<string, any> = {}
|
||||||
for (const season of sd.seasons ?? []) {
|
for (const season of sd.seasons ?? []) {
|
||||||
for (const ep of season.episodes ?? []) {
|
for (const ep of season.episodes ?? []) {
|
||||||
|
let entry: any = null
|
||||||
|
let entryHash = 'manual'
|
||||||
for (const p of ep.paths ?? []) {
|
for (const p of ep.paths ?? []) {
|
||||||
if (typeof p !== 'object' || !p.infohash) continue
|
if (typeof p !== 'object' || !p.infohash) continue
|
||||||
const hash = p.infohash.toLowerCase()
|
const h = p.infohash.toLowerCase()
|
||||||
const entry = (organized[hash] ?? {})[String(ep.id)]
|
const e = (organized[h] ?? {})[String(ep.id)]
|
||||||
if (entry) { result[String(ep.id)] = { ...entry, hash }; break }
|
if (e) { entry = e; entryHash = h; break }
|
||||||
}
|
}
|
||||||
if (!result[String(ep.id)] && organized['manual']?.[String(ep.id)]) {
|
if (!entry && organized['manual']?.[String(ep.id)]) {
|
||||||
result[String(ep.id)] = organized['manual'][String(ep.id)]
|
entry = organized['manual'][String(ep.id)]
|
||||||
}
|
}
|
||||||
|
if (!entry) continue
|
||||||
|
|
||||||
|
// Calculer needs_rename côté serveur avec la même logique que le rename endpoint
|
||||||
|
const currentName = entry.dest_path ? path.basename(entry.dest_path) : entry.dest_filename
|
||||||
|
const srcExt = path.extname(currentName)
|
||||||
|
const { formatted_name: rawFmt, nfo_filename: rawNfo } = resolveEpNaming(ep, entryHash)
|
||||||
|
let expectedName: string
|
||||||
|
if (nfoSupport) {
|
||||||
|
expectedName = rawNfo ? rawNfo.replace(/\.[^.]+$/, '') + srcExt : currentName
|
||||||
|
} else {
|
||||||
|
expectedName = rawFmt?.trim() ? rawFmt.replace(/[<>:"/\\|?*]/g, '').trim() + srcExt : currentName
|
||||||
|
}
|
||||||
|
result[String(ep.id)] = { ...entry, hash: entryHash, needs_rename: expectedName !== currentName }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.json(result)
|
res.json(result)
|
||||||
|
|||||||
@@ -519,8 +519,7 @@ function epExpectedName(ep: any): string {
|
|||||||
function epNeedsRename(ep: any): boolean {
|
function epNeedsRename(ep: any): boolean {
|
||||||
const entry = props.organizedByEpisode[String(ep.id)]
|
const entry = props.organizedByEpisode[String(ep.id)]
|
||||||
if (!entry) return false
|
if (!entry) return false
|
||||||
const expected = epExpectedName(ep)
|
return entry.needs_rename === true
|
||||||
return !!expected && expected !== entry.dest_filename
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Extraction épisodes / chapitres depuis le synopsis ─────────
|
// ── Extraction épisodes / chapitres depuis le synopsis ─────────
|
||||||
|
|||||||
Reference in new issue
Block a user