Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce63ae9a16 | ||
|
|
70d80ccd17 | ||
|
|
7833fbe292 | ||
|
|
fa6aa74442 | ||
|
|
fe2ed9fb76 | ||
|
|
cc655b9e00 | ||
|
|
e1d2a55a01 | ||
|
|
a31de0ef9d | ||
|
|
2853334d7f | ||
|
|
69dd28d31b | ||
|
|
56afce02ea | ||
|
|
bc4697061e | ||
|
|
55ffe85f77 |
@@ -1,6 +1,6 @@
|
||||
# Crunchy.js: a fork of Deathspike/CrunchyRoll.js
|
||||
# Crunchy: a fork of Deathspike/CrunchyRoll.js
|
||||
|
||||
*Crunchy.js* is capable of downloading *anime* episodes from the popular *CrunchyRoll* streaming service. An episode is stored in the original video format (often H.264 in a MP4 container) and the configured subtitle format (ASS or SRT).The two output files are then merged into a single MKV file.
|
||||
*Crunchy* is capable of downloading *anime* episodes from the popular *CrunchyRoll* streaming service. An episode is stored in the original video format (often H.264 in a MP4 container) and the configured subtitle format (ASS or SRT).The two output files are then merged into a single MKV file.
|
||||
|
||||
## Motivation
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
This application is not endorsed or affliated with *CrunchyRoll*. The usage of this application enables episodes to be downloaded for offline convenience which may be forbidden by law in your country. Usage of this application may also cause a violation of the agreed *Terms of Service* between you and the stream provider. A tool is not responsible for your actions; please make an informed decision prior to using this application.
|
||||
|
||||
**PLEASE USE THIS TOOL ONLY IF YOU HAVE A PREMIUM ACCOUNT**
|
||||
**PLEASE _ONLY_ USE THIS TOOL IF YOU HAVE A _PREMIUM ACCOUNT_**
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
@@ -12,16 +12,16 @@
|
||||
"type": "git",
|
||||
"url": "git://github.com/Godzil/crunchyroll.js.git"
|
||||
},
|
||||
"version": "1.1.9",
|
||||
"version": "1.1.12",
|
||||
"bin": {
|
||||
"crunchy": "./bin/crunchy"
|
||||
},
|
||||
"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": {
|
||||
|
||||
@@ -51,8 +51,8 @@ function fileExist(path: string) {
|
||||
*/
|
||||
function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, done: (err: Error, ign: boolean) => void) {
|
||||
var series = config.series || page.series;
|
||||
series = series.replace("/","_").replace("'","_");
|
||||
var fileName = name(config, page, series, "").replace("/","_").replace("'","_");
|
||||
series = series.replace("/","_").replace("'","_").replace(":","_");
|
||||
var fileName = name(config, page, series, "").replace("/","_").replace("'","_").replace(":","_");
|
||||
var filePath = path.join(config.output || process.cwd(), series, fileName);
|
||||
if (fileExist(filePath + ".mkv"))
|
||||
{
|
||||
@@ -61,7 +61,7 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d
|
||||
do
|
||||
{
|
||||
count = count + 1;
|
||||
fileName = name(config, page, series, "-" + count).replace("/","_").replace("'","_");
|
||||
fileName = name(config, page, series, "-" + count).replace("/","_").replace("'","_").replace(":","_");
|
||||
filePath = path.join(config.output || process.cwd(), series, fileName);
|
||||
} while(fileExist(filePath + ".mkv"))
|
||||
console.info("Renaming to '"+fileName+"'...");
|
||||
@@ -137,7 +137,7 @@ function name(config: IConfig, page: IEpisodePage, series: string, extra: string
|
||||
var episode = (episodeNum < 10 ? '0' : '') + page.episode;
|
||||
var volume = (volumeNum < 10 ? '0' : '') + page.volume;
|
||||
var tag = config.tag || 'CrunchyRoll';
|
||||
return series + ' ' + volume + 'x' + episode + extra + ' [' + tag + ']';
|
||||
return series + ' - s' + volume + 'e' + episode +' - [' + tag + ']' + extra;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
'use strict';
|
||||
import request = require('request');
|
||||
import cheerio = require('cheerio');
|
||||
|
||||
var isAuthenticated = false;
|
||||
var isPremium = false;
|
||||
|
||||
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'
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs a GET request for the resource.
|
||||
@@ -33,20 +41,49 @@ export function post(config: IConfig, options: request.Options, done: (err: Erro
|
||||
*/
|
||||
function authenticate(config: IConfig, done: (err: Error) => void) {
|
||||
if (isAuthenticated || !config.pass || !config.user) return done(null);
|
||||
var options = {
|
||||
form: {
|
||||
formname: 'RpcApiUser_Login',
|
||||
fail_url: 'https://www.crunchyroll.com/login',
|
||||
name: config.user,
|
||||
password: config.pass
|
||||
},
|
||||
|
||||
/* Bypass the login page and send a login request directly */
|
||||
var options =
|
||||
{
|
||||
headers: defaultHeaders,
|
||||
jar: true,
|
||||
url: 'https://www.crunchyroll.com/?a=formhandler'
|
||||
gzip: false,
|
||||
url: 'https://www.crunchyroll.com/?a=formhandler&formname=RpcApiUser_Login&name=' + config.user + '&password=' + config.pass
|
||||
};
|
||||
request.post(options, (err: Error) => {
|
||||
|
||||
request(options, (err: Error, rep: string, body: string) =>
|
||||
{
|
||||
if (err) return done(err);
|
||||
isAuthenticated = true;
|
||||
done(null);
|
||||
/* The page return with a meta based redirection, as we wan't to check that everything is fine, reload
|
||||
* the main page. A bit convoluted, but more sure.
|
||||
*/
|
||||
var options =
|
||||
{
|
||||
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++)
|
||||
{
|
||||
if ((dims[i] !== undefined) && (dims[i] !== '') && (dims[i] !== 'not-registered')) { isAuthenticated = true; }
|
||||
if ((dims[i] === 'premium') || (dims[i] === 'premiumplus')) { isPremium = true; }
|
||||
}
|
||||
if (isAuthenticated === false)
|
||||
{
|
||||
var error = $('ul.message, li.error').text();
|
||||
return done(new Error('Authentication failed: ' + error));
|
||||
}
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,7 +93,8 @@ function authenticate(config: IConfig, done: (err: Error) => void) {
|
||||
function modify(options: string|request.Options): request.Options {
|
||||
if (typeof options !== 'string') {
|
||||
options.jar = true;
|
||||
options.headers = defaultHeaders;
|
||||
return options;
|
||||
}
|
||||
return {jar: true, url: options.toString()};
|
||||
return {jar: true, headers: defaultHeaders, url: options.toString()};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user