From fa4c68c239a5a9b4f9f445dfc2be6df7f829efa1 Mon Sep 17 00:00:00 2001 From: elisha464 Date: Sat, 30 Nov 2019 16:32:24 +0200 Subject: [PATCH] fix logUsingCookie * it seems that the site only cares about the cookie `session_id` * when checking if the user is authenticated the cookie jar was not being used --- src/my_request.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/my_request.ts b/src/my_request.ts index 39dbe9d..dfdd677 100644 --- a/src/my_request.ts +++ b/src/my_request.ts @@ -110,7 +110,7 @@ function checkIfUserIsAuth(config: IConfig, done: (err: Error) => void): void */ const url = 'http://www.crunchyroll.com/'; - cloudscraper.get({gzip: true, uri: url}, (err: Error, rep: string, body: string) => + cloudscraper.get({gzip: true, uri: url, jar: j}, (err: Error, rep: string, body: string) => { if (err) { @@ -338,9 +338,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) } else if (config.logUsingCookie) { - j.setCookie(request.cookie('c_userid=' + config.crUserId + '; Domain=crunchyroll.com; HttpOnly; hostOnly=false;'), - CR_COOKIE_DOMAIN); - j.setCookie(request.cookie('c_userkey=' + config.crUserKey + '; Domain=crunchyroll.com; HttpOnly; hostOnly=false;'), + j.setCookie(request.cookie('session_id=' + config.crSessionId + '; Domain=crunchyroll.com; HttpOnly; hostOnly=false;'), CR_COOKIE_DOMAIN); checkIfUserIsAuth(config, (errCheckAuth2) =>