fix(scrap): Correction fallback si scraper KO
This commit is contained in:
1 parent
c6b26d88f0
commit
6348cc40cb
3 files changed
+9
-13
No files matched your search
@@ -109,10 +109,11 @@ function readOrganized(): Record<string, Record<string, any>> {
|
||||
function getOrganizedEpisodeIds(sd: any, organized: Record<string, Record<string, any>>): 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 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 ?? []) {
|
||||
const orgFiles = organized[t.infohash?.toLowerCase()] ?? {}
|
||||
|
||||
@@ -246,15 +246,9 @@ export function computeSerieDownloadState(serieData: any | null, organized: Reco
|
||||
}
|
||||
}
|
||||
|
||||
const manualOrg = organized['manual'] ?? {}
|
||||
for (const season of serieData.seasons ?? []) {
|
||||
for (const ep of season.episodes ?? []) {
|
||||
if (manualOrg[String(ep.id)]) {
|
||||
const key = epIdToKey.get(ep.id)
|
||||
if (key) organizedEpKeys.add(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
const trackedIds = new Set(Object.values(organized).flatMap(eps => Object.keys(eps)))
|
||||
for (const [id, key] of epIdToKey)
|
||||
if (trackedIds.has(String(id))) organizedEpKeys.add(key)
|
||||
|
||||
if (uniqueEpKeys.size === 0 || organizedEpKeys.size === 0) return 'none'
|
||||
if (organizedEpKeys.size >= uniqueEpKeys.size) return 'complete'
|
||||
|
||||
@@ -58,10 +58,11 @@ router.get('/series/:id', requireAuth, async (req, res) => {
|
||||
const integraleTorrents : any[] = []
|
||||
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 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) {
|
||||
|
||||
Reference in new issue
Block a user