Merge pull request #146 from Nackophilz/main

fix(scrap): Correction fallback si scraper KO
This commit is contained in:
Quentin Robert authored and GitHub committed 2026-09-12 02:36:56 +02:00
commit f64d2e19f7
3 files changed
+9 -13

No files matched your search

+3 -2
View File
@@ -109,10 +109,11 @@ function readOrganized(): Record<string, Record<string, any>> {
function getOrganizedEpisodeIds(sd: any, organized: Record<string, Record<string, any>>): Set<number> { function getOrganizedEpisodeIds(sd: any, organized: Record<string, Record<string, any>>): Set<number> {
const ids = new Set<number>() const ids = new Set<number>()
const manual = organized['manual'] ?? {} // Sous n'importe quel hash : évite de retélécharger un épisode importé via un torrent disparu du scraper
const tracked = new Set(Object.values(organized).flatMap(eps => Object.keys(eps)))
for (const season of sd.seasons ?? []) for (const season of sd.seasons ?? [])
for (const ep of season.episodes ?? []) for (const ep of season.episodes ?? [])
if (manual[String(ep.id)]) ids.add(ep.id) if (tracked.has(String(ep.id))) ids.add(ep.id)
for (const t of sd.torrents ?? []) { for (const t of sd.torrents ?? []) {
const orgFiles = organized[t.infohash?.toLowerCase()] ?? {} const orgFiles = organized[t.infohash?.toLowerCase()] ?? {}
+3 -9
View File
@@ -246,15 +246,9 @@ export function computeSerieDownloadState(serieData: any | null, organized: Reco
} }
} }
const manualOrg = organized['manual'] ?? {} const trackedIds = new Set(Object.values(organized).flatMap(eps => Object.keys(eps)))
for (const season of serieData.seasons ?? []) { for (const [id, key] of epIdToKey)
for (const ep of season.episodes ?? []) { if (trackedIds.has(String(id))) organizedEpKeys.add(key)
if (manualOrg[String(ep.id)]) {
const key = epIdToKey.get(ep.id)
if (key) organizedEpKeys.add(key)
}
}
}
if (uniqueEpKeys.size === 0 || organizedEpKeys.size === 0) return 'none' if (uniqueEpKeys.size === 0 || organizedEpKeys.size === 0) return 'none'
if (organizedEpKeys.size >= uniqueEpKeys.size) return 'complete' if (organizedEpKeys.size >= uniqueEpKeys.size) return 'complete'
+3 -2
View File
@@ -58,10 +58,11 @@ router.get('/series/:id', requireAuth, async (req, res) => {
const integraleTorrents : any[] = [] const integraleTorrents : any[] = []
const organizedEpisodeIds = new Set<number>() const organizedEpisodeIds = new Set<number>()
const manualOrg = organized['manual'] ?? {} // Importé = une entrée pour l'épisode sous n'importe quel hash : les torrents du scraper peuvent disparaître
const trackedIds = new Set(Object.values(organized).flatMap(eps => Object.keys(eps)))
for (const season of seasonsWithEpisodes) { for (const season of seasonsWithEpisodes) {
for (const ep of season.episodes) { for (const ep of season.episodes) {
if (manualOrg[String(ep.id)]) organizedEpisodeIds.add(ep.id) if (trackedIds.has(String(ep.id))) organizedEpisodeIds.add(ep.id)
} }
} }
if (serieData) { if (serieData) {