Update dependency to more recent version, and correct a few warnings reported by ts

This commit is contained in:
Godzil
2017-01-23 21:06:34 +00:00
parent 7833fbe292
commit 70d80ccd17
2 changed files with 15 additions and 15 deletions

View File

@@ -18,10 +18,10 @@
},
"dependencies": {
"big-integer": "1.4.4",
"cheerio": "0.18.0",
"cheerio": "0.22.0",
"commander": "2.6.0",
"mkdirp": "0.5.0",
"request": "2.53.0",
"request": "2.74.0",
"xml2js": "0.4.5"
},
"devDependencies": {

View File

@@ -5,7 +5,7 @@ import cheerio = require('cheerio');
var isAuthenticated = false;
var isPremium = false;
var defaultHeaders:request.Headers = {
var defaultHeaders: request.Headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0',
'Connection': 'keep-alive'
};
@@ -62,29 +62,29 @@ function authenticate(config: IConfig, done: (err: Error) => void) {
headers: defaultHeaders,
jar: true,
url: 'http://www.crunchyroll.com/'
}
};
request(options, (err: Error, rep: string, body: string) =>
{
if (err) return done(err);
var $ = cheerio.load(body);
/* Check if auth worked */
var regexps = /ga\(\'set\', \'dimension[5-8]\', \'([^']*)\'\);/g
var dims = regexps.exec($('script').text())
for(var i = 1; i < 5; i++)
var regexps = /ga\(\'set\', \'dimension[5-8]\', \'([^']*)\'\);/g;
var dims = regexps.exec($('script').text());
for (var i = 1; i < 5; i++)
{
if ((dims[i] != undefined) && (dims[i] != "") && (dims[i] != "not-registered")) { isAuthenticated = true; }
if ((dims[i] == "premium") || (dims[i] == "premiumplus")) { isPremium = true; }
if ((dims[i] !== undefined) && (dims[i] !== '') && (dims[i] !== 'not-registered')) { isAuthenticated = true; }
if ((dims[i] === 'premium') || (dims[i] === 'premiumplus')) { isPremium = true; }
}
if (isAuthenticated == false)
if (isAuthenticated === false)
{
var error = $('ul.message, li.error').text();
return done(new Error("Authentication failed: " + error));
return done(new Error('Authentication failed: ' + error));
}
if (isPremium == false) { console.info("Do not use this app without a premium account."); }
else { console.info("You have a premium account! Good!"); }
if (isPremium === false) { console.log('Do not use this app without a premium account.'); }
else { console.log('You have a premium account! Good!'); }
done(null);
})
})
});
});
}
/**