From 1f50f9ae72ec9958bfb92b2e6936c699e19272f3 Mon Sep 17 00:00:00 2001 From: MasutaYunikon Date: Thu, 7 May 2026 15:07:17 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20on=20ne=20vois=20plus=20le=20telechargem?= =?UTF-8?q?ent=20de=20fichier=20qui=20ont=20une=20priorit=C3=A9=20basse=20?= =?UTF-8?q?(ne=20pas=20t=C3=A9l=C3=A9charger)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/torrent-clients/index.ts | 1 + server/torrent-clients/qbittorrent.ts | 17 ++++++----------- src/components/serie/SerieSeasonCard.vue | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/server/torrent-clients/index.ts b/server/torrent-clients/index.ts index a84aae5..6984310 100644 --- a/server/torrent-clients/index.ts +++ b/server/torrent-clients/index.ts @@ -38,6 +38,7 @@ export interface TorrentFileProgress { index : number name ?: string // chemin relatif dans le torrent (ex: "Pack S1/Episode1.mkv") — optionnel selon le client progress: number // 0–1 + priority: number // 0 = do not download, 1 = normal, 6 = high, 7 = max } export interface TorrentInfo { diff --git a/server/torrent-clients/qbittorrent.ts b/server/torrent-clients/qbittorrent.ts index b240fea..636dae9 100644 --- a/server/torrent-clients/qbittorrent.ts +++ b/server/torrent-clients/qbittorrent.ts @@ -24,8 +24,6 @@ async function qbAuth(config: Record): Promise ; en <5.2.0, c'est SID. async function qbLogin(config: Record): Promise { const form = new URLSearchParams() form.append('username', String(config.username ?? '')) @@ -37,17 +35,12 @@ async function qbLogin(config: Record): Promise headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, }) - const text = await res.text() - const setCookie = res.headers.get('set-cookie') ?? '' - - // ≥5.2.0 : HTTP 204, body vide | <5.2.0 : HTTP 200, body "Ok." + const text = await res.text() if (!res.ok) throw new Error(`Login échoué : ${text.trim() || res.status}`) - // ≥5.2.0 : QBT_SID_= | <5.2.0 : SID= - const match = setCookie.match(/(?:QBT_SID_\d+|SID)=([^;]+)/) - if (!match) throw new Error(`Cookie SID introuvable (set-cookie reçu : "${setCookie}")`) - // match[0] = "QBT_SID_8080=abc123" ou "SID=abc123" — on renvoie le pair complet - return match[0] + const cookie = (res.headers.get('set-cookie') ?? '').split(';')[0].trim() + if (!cookie) throw new Error('Cookie de session introuvable') + return cookie } async function qbTorrentExists(config: Record, authHeaders: Record, hash: string): Promise { @@ -246,6 +239,7 @@ const QB: TorrentClientDriver = { index : i, name : String(f.name ?? ''), progress: f.progress ?? 0, // 0–1 + priority: f.priority ?? 1, })) : undefined, } satisfies TorrentInfo @@ -263,6 +257,7 @@ const QB: TorrentClientDriver = { index : i, name : String(f.name ?? ''), progress: f.progress ?? 0, + priority: f.priority ?? 1, })) }, diff --git a/src/components/serie/SerieSeasonCard.vue b/src/components/serie/SerieSeasonCard.vue index b479ad3..13a6053 100644 --- a/src/components/serie/SerieSeasonCard.vue +++ b/src/components/serie/SerieSeasonCard.vue @@ -441,7 +441,7 @@ function epProgress(ep: any): ActiveTorrent | null { // Avec données par fichier on se fie à la progression réelle du fichier précis. // Si le fichier est à 100% sans session active → déjà téléchargé hors session // (ex : désimporté puis re-consulté) → ne pas afficher le spinner. - if (file != null && (sessionDl || (file.progress > 0 && file.progress < 1))) { + if (file != null && file.priority !== 0 && (sessionDl || (file.progress > 0 && file.progress < 1))) { return { ...active, progress: Math.round(file.progress * 100) } } if (!sessionDl) continue