Merge pull request #108 from Ronserruya/fix_title_scrape
Fix login and only direct links issues. Still need to understand what is happening.
This commit is contained in:
commit
ca59e3b2fd
@ -314,7 +314,7 @@ function authenticate(config: IConfig, done: (err: Error) => void)
|
|||||||
startSession(config)
|
startSession(config)
|
||||||
.then((sessionId: string) =>
|
.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);
|
return APIlogin(config, sessionId, config.user, config.pass);
|
||||||
})
|
})
|
||||||
.then((userData) =>
|
.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 */
|
/* First get https://www.crunchyroll.com/login to get the login token */
|
||||||
const options =
|
const options =
|
||||||
{
|
{
|
||||||
jar: j,
|
// jar: j,
|
||||||
uri: 'https://www.crunchyroll.com/login'
|
uri: 'https://www.crunchyroll.com/login'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ function authenticate(config: IConfig, done: (err: Error) => void)
|
|||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
|
||||||
console.log('------- GET --------');
|
console.log('------- GET --------');
|
||||||
//console.error(err);
|
// console.error(err);
|
||||||
console.log(body);
|
console.log(body);
|
||||||
console.log('------- /GET --------');
|
console.log('------- /GET --------');
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ function authenticate(config: IConfig, done: (err: Error) => void)
|
|||||||
{
|
{
|
||||||
return done(AuthError('Can\'t find token!'));
|
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 */
|
/* Now call the page again with the token and credentials */
|
||||||
const options =
|
const options =
|
||||||
{
|
{
|
||||||
@ -392,7 +392,7 @@ function authenticate(config: IConfig, done: (err: Error) => void)
|
|||||||
'login_form[redirect_url]': '/',
|
'login_form[redirect_url]': '/',
|
||||||
'login_form[_token]': token
|
'login_form[_token]': token
|
||||||
},
|
},
|
||||||
jar: j,
|
// jar: j,
|
||||||
url: 'https://www.crunchyroll.com/login'
|
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) =>
|
cloudscraper.post(options, (err: Error, rep: string, body: string) =>
|
||||||
{
|
{
|
||||||
console.log('------- POST --------');
|
console.log('------- POST --------');
|
||||||
//console.error(err);
|
// console.error(err);
|
||||||
console.log(body);
|
console.log(body);
|
||||||
console.log('------- /POST --------');
|
console.log('------- /POST --------');
|
||||||
|
|
||||||
|
|||||||
@ -198,7 +198,7 @@ function pageScrape(config: IConfig, task: IConfigTask, done: (err: any, result?
|
|||||||
}
|
}
|
||||||
|
|
||||||
const $ = cheerio.load(result);
|
const $ = cheerio.load(result);
|
||||||
const title = $('span[itemprop=name]').text();
|
const title = $('meta[itemprop=name]').attr('content');
|
||||||
|
|
||||||
if (config.debug)
|
if (config.debug)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user