fix: sign-in detection case-insensitive, auto retry with Chrome cookies
This commit is contained in:
parent
92bcc70728
commit
ee59ba8247
1 changed files with 8 additions and 4 deletions
12
bm.js
12
bm.js
|
|
@ -245,16 +245,20 @@ function doDownload(url, fmtIdx, retry403 = false) {
|
|||
dlProc.stdout.on('data', onData)
|
||||
dlProc.stderr.on('data', d => {
|
||||
const line = d.toString()
|
||||
const lineL = line.toLowerCase()
|
||||
if (parseProgress(line)) { render(); return }
|
||||
if (line.includes('ERROR') || line.includes('error')) {
|
||||
lastErr = line.replace(/\x1b\[[0-9;]*m/g, '').trim().slice(0, 80)
|
||||
if (lineL.includes('error') || lineL.includes('warning')) {
|
||||
lastErr = line.replace(/\x1b\[[0-9;]*m/g, '').trim().slice(0, 90)
|
||||
st.msg = lastErr
|
||||
render()
|
||||
}
|
||||
if (!got403 && (line.includes('HTTP Error 403') || line.includes('Sign in'))) {
|
||||
const needsCookies = lineL.includes('403') || lineL.includes('sign in') ||
|
||||
lineL.includes('please sign') || lineL.includes('cookies-from-browser') ||
|
||||
lineL.includes('login required') || lineL.includes('not available')
|
||||
if (!got403 && needsCookies && !retry403) {
|
||||
got403 = true
|
||||
dlProc.kill()
|
||||
st.msg = '403 — retry с куками Chrome...'
|
||||
st.msg = 'нужны куки Chrome — retry...'
|
||||
render()
|
||||
doDownload(url, fmtIdx, true)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue