Fix qBittorrent 5.x session cookie name (SID -> QBT_SID_{port})
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -14,11 +14,8 @@ async function getCookie(): Promise<string> {
|
|||||||
const pass = process.env.QBT_PASSWORD
|
const pass = process.env.QBT_PASSWORD
|
||||||
if (!host || !user || !pass) throw new Error('QBT_HOST / QBT_USER / QBT_PASSWORD not configured')
|
if (!host || !user || !pass) throw new Error('QBT_HOST / QBT_USER / QBT_PASSWORD not configured')
|
||||||
|
|
||||||
const loginUrl = `${host}/api/v2/auth/login`
|
|
||||||
console.log(`[qbt] POST ${loginUrl} user=${user}`)
|
|
||||||
|
|
||||||
const res = await axios.post(
|
const res = await axios.post(
|
||||||
loginUrl,
|
`${host}/api/v2/auth/login`,
|
||||||
new URLSearchParams({ username: user, password: pass }),
|
new URLSearchParams({ username: user, password: pass }),
|
||||||
{
|
{
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Referer': host, 'Origin': host },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Referer': host, 'Origin': host },
|
||||||
@@ -26,9 +23,8 @@ async function getCookie(): Promise<string> {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log(`[qbt] status=${res.status} headers=${JSON.stringify(res.headers)} body=${JSON.stringify(res.data)}`)
|
// qBittorrent 5.x renamed the cookie from SID to QBT_SID_{port}
|
||||||
|
const cookie = (res.headers['set-cookie'] ?? []).find((c: string) => /^(QBT_)?SID[_=]/.test(c))
|
||||||
const cookie = (res.headers['set-cookie'] ?? []).find((c: string) => c.startsWith('SID='))
|
|
||||||
if (!cookie) throw new Error(`qBittorrent login failed (${res.status}): "${String(res.data).trim()}"`)
|
if (!cookie) throw new Error(`qBittorrent login failed (${res.status}): "${String(res.data).trim()}"`)
|
||||||
|
|
||||||
sid = cookie.split(';')[0]
|
sid = cookie.split(';')[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user