From c9040ea68c52e65a656824ccfd101a04a2251edd Mon Sep 17 00:00:00 2001 From: MasutaYunikon Date: Mon, 11 May 2026 19:12:10 +0200 Subject: [PATCH] fix(download): le telechargement de saison ne propose plus tout les torrents des episodes de la saisons si la serie n'a que des torrent par episodes --- src/components/serie/SerieSeasonCard.vue | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/serie/SerieSeasonCard.vue b/src/components/serie/SerieSeasonCard.vue index 07bce1f..49d7361 100644 --- a/src/components/serie/SerieSeasonCard.vue +++ b/src/components/serie/SerieSeasonCard.vue @@ -594,23 +594,33 @@ function groupLabels(torrents: any[]): string[] { } // Packs parents distincts couvrant cette saison (quand pas de pack saison explicite) -// Permet le dropdown "Saison ▾" quand une saison est couverte par plusieurs intégrales +// Permet le dropdown "Saison ▾" quand une saison est couverte par plusieurs intégrales. +// Un torrent individuel par épisode (hash unique) n'est PAS un pack → ignoré ici, +// le bouton "Saison" simple suffira pour lancer tous les épisodes. const uniquePackOptions = computed(() => { if (props.season.torrents?.length) return [] - const seen = new Set() - const raw: { infohash: string; torrent: any }[] = [] + + // Compter combien d'épisodes chaque hash couvre + const hashCount = new Map() + const hashTorrent = new Map() for (const ep of props.season.episodes) { if (!ep.available) continue for (const t of (ep.torrents ?? [])) { const hash = t.infohash ?? extractHash(t) - if (!hash || seen.has(hash)) continue - seen.add(hash) - raw.push({ infohash: hash, torrent: t }) + if (!hash) continue + hashCount.set(hash, (hashCount.get(hash) ?? 0) + 1) + if (!hashTorrent.has(hash)) hashTorrent.set(hash, t) } } - if (raw.length <= 1) return [] - const labels = groupLabels(raw.map(r => r.torrent)) - return raw.map((r, i) => ({ infohash: r.infohash, label: labels[i] })) + + // Garder uniquement les hash qui couvrent ≥ 2 épisodes (= vrais packs / intégrales) + const packs = [...hashCount.entries()] + .filter(([, count]) => count > 1) + .map(([hash]) => ({ infohash: hash, torrent: hashTorrent.get(hash)! })) + + if (packs.length <= 1) return [] + const labels = groupLabels(packs.map(r => r.torrent)) + return packs.map((r, i) => ({ infohash: r.infohash, label: labels[i] })) }) function formatDate(d: string): string {