Skip to content

Commit 6125e96

Browse files
committed
Error handling for invalid auth cookie
1 parent 362f6d4 commit 6125e96

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,5 @@ To use this, the variables in .env need to be configured first, and then in the
1212
node index.js
1313
```
1414

15-
## Known Issues:
16-
1. Accepts invalid auth cookie input meaning that any video it will add will be added as temporary
17-
1815
## ToDo:
19-
1. Error handling for invalid auth cookie input
16+
1. If there's a disconnection because of a duplicate login, pause the execution and press enter to resume rather than having to rerun the script

cytube_auto.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@ function update_playlist(cookie, headless, queue_delay, url, check_blacklisted)
99
puppeteer.launch({ headless: headless}).then(async browser => {
1010
const page = await browser.newPage()
1111

12-
await page.setCookie(cookie)
13-
await page.goto(url)
14-
1512
const archive_data = await get_archive_csv('https://docs.google.com/spreadsheets/d/1rEofPkliKppvttd8pEX8H6DtSljlfmQLdFR-SlyyX7E/export?format=csv')
1613

17-
// since a browser is being used, a delay is needeed so all the necessary elements have time to load
18-
await delay(2500)
14+
while (true) {
15+
await page.setCookie(cookie)
16+
await page.goto(url)
17+
18+
// since a browser is being used, a delay is needeed so all the necessary elements have time to load
19+
await delay(2500)
20+
21+
// if the logout element exists that means that the authentication cookie has worked
22+
if (await page.$('#logout')) break
23+
24+
logErr("Invalid Authentication Cookie Provided")
25+
log()
26+
27+
cookie['value'] = await getInput('Authentication Cookie: ', true)
28+
}
1929

2030
// This is the + button which is needed to reveal the playlist adding video options
2131
await page.click('#showmediaurl')
@@ -110,8 +120,6 @@ function update_playlist(cookie, headless, queue_delay, url, check_blacklisted)
110120
await page.click('#queue_end')
111121
await delay(queue_delay + (!headless * 1000))
112122

113-
114-
115123
log(`${csv_row}: not present - Title: ${videoData[index.TITLE]}\n${alternate ? 'adding using alt link...' : 'adding...'}\n`)
116124

117125
++add_vid_attempts

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ async function main() {
6969
cookie = cookie,
7070
headless = !flags['-show'],
7171
queue_delay = flags['-queuedelay'],
72-
7372
url = channel_url,
7473
check_blacklisted = flags['-checkblacklisted']
7574
)

0 commit comments

Comments
 (0)