Skip to content

Commit 4eb7e0f

Browse files
committed
Just in case
1 parent abe0d05 commit 4eb7e0f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

cytube_auto.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ function update_playlist(cookie, headless, queue_delay, url, check_blacklisted)
1515
await page.setCookie(cookie)
1616
await page.goto(url)
1717

18-
// since a browser is being used, a delay is needeed so all the necessary elements have time to load
19-
await delay(2500)
18+
// since a browser is being used, a delay might be needeed so all the necessary elements have time to load
19+
await delay(2500 + (!headless * 1000))
2020

2121
// if the logout element exists that means that the authentication cookie has worked
22-
if (await page.$('#logout')) break
22+
let logged_in = await page.$('#logout')
23+
let retries = 0
2324

24-
logErr("Invalid Authentication Cookie Provided")
25+
while (!logged_in && retries < 3) {
26+
logErr("Indicator of successful login is absent\nRetrying...")
27+
logged_in = await page.$('#logout')
28+
await delay(1000)
29+
if (logged_in) break
30+
}
31+
32+
if (logged_in) break
33+
34+
logErr("\nConclusion: Invalid Authentication Cookie Provided")
2535
log()
2636

2737
cookie['value'] = await getInput('Authentication Cookie: ', true)

0 commit comments

Comments
 (0)