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