From 48a58ffca6b5db6ad835dcb8457a73106e247dd4 Mon Sep 17 00:00:00 2001 From: ronserruya Date: Wed, 31 Jul 2019 14:26:13 +0300 Subject: [PATCH 1/3] Fix login issue --- src/my_request.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/my_request.ts b/src/my_request.ts index 017fcb2..545b256 100644 --- a/src/my_request.ts +++ b/src/my_request.ts @@ -360,7 +360,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) /* First get https://www.crunchyroll.com/login to get the login token */ const options = { - jar: j, + //jar: j, uri: 'https://www.crunchyroll.com/login' }; @@ -392,7 +392,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) 'login_form[redirect_url]': '/', 'login_form[_token]': token }, - jar: j, + //jar: j, url: 'https://www.crunchyroll.com/login' }; From 0d2d36251a617141bca8385a3dc41d464891ae4d Mon Sep 17 00:00:00 2001 From: ronserruya Date: Wed, 31 Jul 2019 14:26:22 +0300 Subject: [PATCH 2/3] Fix title fetching --- src/series.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/series.ts b/src/series.ts index 20f7137..d358eb0 100644 --- a/src/series.ts +++ b/src/series.ts @@ -198,7 +198,7 @@ function pageScrape(config: IConfig, task: IConfigTask, done: (err: any, result? } const $ = cheerio.load(result); - const title = $('span[itemprop=name]').text(); + const title = $('meta[itemprop=name]').attr("content") if (config.debug) { From 95c0c4d6d30d801e28d07817ddd0b388dd99dabb Mon Sep 17 00:00:00 2001 From: ronserruya Date: Wed, 31 Jul 2019 14:29:49 +0300 Subject: [PATCH 3/3] Linter stuff --- src/my_request.ts | 12 ++++++------ src/series.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/my_request.ts b/src/my_request.ts index 545b256..0b93abd 100644 --- a/src/my_request.ts +++ b/src/my_request.ts @@ -314,7 +314,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) startSession(config) .then((sessionId: string) => { - //defaultHeaders['Cookie'] = `sess_id=${sessionId}; c_locale=enUS`; + // defaultHeaders['Cookie'] = `sess_id=${sessionId}; c_locale=enUS`; return APIlogin(config, sessionId, config.user, config.pass); }) .then((userData) => @@ -360,7 +360,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) /* First get https://www.crunchyroll.com/login to get the login token */ const options = { - //jar: j, + // jar: j, uri: 'https://www.crunchyroll.com/login' }; @@ -369,7 +369,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) if (err) return done(err); console.log('------- GET --------'); - //console.error(err); + // console.error(err); console.log(body); console.log('------- /GET --------'); @@ -381,7 +381,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) { return done(AuthError('Can\'t find token!')); } - console.log("Token: " + token); + console.log('Token: ' + token); /* Now call the page again with the token and credentials */ const options = { @@ -392,7 +392,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) 'login_form[redirect_url]': '/', 'login_form[_token]': token }, - //jar: j, + // jar: j, url: 'https://www.crunchyroll.com/login' }; @@ -401,7 +401,7 @@ function authenticate(config: IConfig, done: (err: Error) => void) cloudscraper.post(options, (err: Error, rep: string, body: string) => { console.log('------- POST --------'); - //console.error(err); + // console.error(err); console.log(body); console.log('------- /POST --------'); diff --git a/src/series.ts b/src/series.ts index d358eb0..d88f445 100644 --- a/src/series.ts +++ b/src/series.ts @@ -198,7 +198,7 @@ function pageScrape(config: IConfig, task: IConfigTask, done: (err: any, result? } const $ = cheerio.load(result); - const title = $('meta[itemprop=name]').attr("content") + const title = $('meta[itemprop=name]').attr('content'); if (config.debug) {