Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5c4c08e66 | ||
|
|
2b201b0785 | ||
|
|
fdf5805911 | ||
|
|
9191075f48 | ||
|
|
9f73e4f865 | ||
|
|
1f20e028e1 | ||
|
|
da0fb17015 | ||
|
|
2aa71832b3 | ||
|
|
876def4392 | ||
|
|
0ba51b7270 |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "crunchy",
|
||||
"version": "1.4.2-0",
|
||||
"version": "1.4.4",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"engines": {
|
||||
"node": ">=5.0"
|
||||
},
|
||||
"version": "1.4.2-0",
|
||||
"version": "1.4.4",
|
||||
"bin": {
|
||||
"crunchy": "./bin/crunchy",
|
||||
"crunchy.sh": "./bin/crunchy.sh"
|
||||
|
||||
10
src/batch.ts
10
src/batch.ts
@@ -33,6 +33,11 @@ export default function(args: string[], done: (err?: Error) => void)
|
||||
batchPath = path.normalize(path.join(process.cwd(), config.batch));
|
||||
}
|
||||
|
||||
if (config.nametmpl === undefined)
|
||||
{
|
||||
config.nametmpl = '{SERIES_TITLE} - s{SEASON_NUMBER}e{EPISODE_NUMBER} - {EPISODE_TITLE} - [{TAG}]';
|
||||
}
|
||||
|
||||
// Update the config file with new parameters
|
||||
cfg.save(config);
|
||||
|
||||
@@ -88,7 +93,7 @@ export default function(args: string[], done: (err?: Error) => void)
|
||||
return done(err);
|
||||
}
|
||||
|
||||
if (tasksArr[0].address === '')
|
||||
if (!tasksArr || !tasksArr[0] || (tasksArr[0].address === ''))
|
||||
{
|
||||
return done();
|
||||
}
|
||||
@@ -349,11 +354,12 @@ function parse(args: string[]): IConfigLine
|
||||
// Episode filter
|
||||
.option('-e, --episodes <s>', 'Episode list. Read documentation on how to use')
|
||||
// Settings
|
||||
.option('-l, --crlang <s>', 'CR page language (valid: en, fr, es, it, pt, de, ru).')
|
||||
.option('-f, --format <s>', 'The subtitle format.', 'ass')
|
||||
.option('-o, --output <s>', 'The output path.')
|
||||
.option('-s, --series <s>', 'The series name override.')
|
||||
.option('--ignoredub', 'Experimental: Ignore all seasons where the title end with \'Dub)\'')
|
||||
.option('-n, --nametmpl <s>', 'Output name template', '{SERIES_TITLE} - s{SEASON_NUMBER}e{EPISODE_NUMBER} - {EPISODE_TITLE} - [{TAG}]')
|
||||
.option('-n, --nametmpl <s>', 'Output name template')
|
||||
.option('-t, --tag <s>', 'The subgroup.', 'CrunchyRoll')
|
||||
.option('-r, --resolution <s>', 'The video resolution. (valid: 360, 480, 720, 1080)', '1080')
|
||||
.option('-b, --batch <s>', 'Batch file', 'CrunchyRoll.txt')
|
||||
|
||||
23
src/cli.ts
23
src/cli.ts
@@ -11,18 +11,25 @@ log.info('Crunchy version ' + current_version);
|
||||
request.get({ uri: 'https://box.godzil.net/getVersion.php?tool=crunchy&v=' + current_version },
|
||||
(error: Error, response: any, body: any) =>
|
||||
{
|
||||
const onlinepkg = JSON.parse(body);
|
||||
if (onlinepkg.status === 'ok')
|
||||
if (response && (response.StatusCode === 200))
|
||||
{
|
||||
let tmp = current_version.split('.');
|
||||
const cur = (Number(tmp[0]) * 10000) + (Number(tmp[1]) * 100) + Number(tmp[2]);
|
||||
tmp = onlinepkg.version.split('.');
|
||||
const dist = (Number(tmp[0]) * 10000) + (Number(tmp[1]) * 100) + Number(tmp[2]);
|
||||
if (dist > cur)
|
||||
const onlinepkg = JSON.parse(body);
|
||||
if (onlinepkg.status === 'ok')
|
||||
{
|
||||
log.warnMore('There is a newer version of crunchy (v' + onlinepkg.version + '), you should update!');
|
||||
let tmp = current_version.split('.');
|
||||
const cur = (Number(tmp[0]) * 10000) + (Number(tmp[1]) * 100) + Number(tmp[2]);
|
||||
tmp = onlinepkg.version.split('.');
|
||||
const dist = (Number(tmp[0]) * 10000) + (Number(tmp[1]) * 100) + Number(tmp[2]);
|
||||
if (dist > cur)
|
||||
{
|
||||
log.warnMore('There is a newer version of crunchy (v' + onlinepkg.version + '), you should update!');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info('Cannot check version.');
|
||||
}
|
||||
});
|
||||
|
||||
batch(process.argv, (err: any) =>
|
||||
|
||||
@@ -66,7 +66,7 @@ function fileExist(path: string)
|
||||
|
||||
function sanitiseFileName(str: string)
|
||||
{
|
||||
return str.replace(/[\/':\?\*"<>\\\.]/g, '_');
|
||||
return str.replace(/[\/':\?\*"<>\\\.\|]/g, '_');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
1
src/interface/IConfig.d.ts
vendored
1
src/interface/IConfig.d.ts
vendored
@@ -7,6 +7,7 @@ interface IConfig {
|
||||
merge?: boolean;
|
||||
episodes?: string;
|
||||
// Settings
|
||||
crlang?: string;
|
||||
format?: string;
|
||||
output?: string;
|
||||
series?: string;
|
||||
|
||||
66
src/languages.ts
Normal file
66
src/languages.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
const localeCC: { [id: string]: string; } =
|
||||
{
|
||||
enUS: 'en', enGB: 'en',
|
||||
esLA: 'es', esES: 'es',
|
||||
ptPT: 'pt', ptBR: 'pt',
|
||||
frFR: 'fr',
|
||||
deDE: 'de',
|
||||
itIT: 'it',
|
||||
ruRU: 'ru',
|
||||
};
|
||||
|
||||
export function localeToCC(locale: string): string
|
||||
{
|
||||
let ret = localeCC.enGB;
|
||||
|
||||
if (locale in localeCC)
|
||||
{
|
||||
ret = localeCC[locale];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const dubignore_regexp: { [id: string]: RegExp; } =
|
||||
{
|
||||
en: /\(.*Dub(?:bed)?.*\)|(?:\(RU\))/i,
|
||||
fr: /\(.*Dub(?:bed)?.*\)|(?:\(RU\))|\(?Doublage.*\)?/,
|
||||
de: /\(.*isch\)|\(Dubbed\)|\(RU\)/
|
||||
};
|
||||
|
||||
export function get_diregexp(config: IConfig): RegExp
|
||||
{
|
||||
let ret = dubignore_regexp.en;
|
||||
|
||||
if (config.crlang in dubignore_regexp)
|
||||
{
|
||||
ret = dubignore_regexp[config.crlang];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const episodes_regexp: { [id: string]: RegExp; } =
|
||||
{
|
||||
en: /Episode\s+((OVA)|(PV )?[S0-9][\-P0-9.]*[a-fA-F]?)\s*$/i,
|
||||
fr: /Épisode\s+((OVA)|(PV )?[S0-9][\-P0-9.]*[a-fA-F]?)\s*$/i,
|
||||
de: /Folge\s+((OVA)|(PV )?[S0-9][\-P0-9.]*[a-fA-F]?)\s*$/i,
|
||||
es: /Episodio\s+((OVA)|(PV )?[S0-9][\-P0-9.]*[a-fA-F]?)\s*$/i,
|
||||
it: /Episodio\s+((OVA)|(PV )?[S0-9][\-P0-9.]*[a-fA-F]?)\s*$/i,
|
||||
pt: /Episódio\s+((OVA)|(PV )?[S0-9][\-P0-9.]*[a-fA-F]?)\s*$/i,
|
||||
ru: /Серия\s+((OVA)|(PV )?[S0-9][\-P0-9.]*[a-fA-F]?)\s*$/i,
|
||||
};
|
||||
|
||||
export function get_epregexp(config: IConfig): RegExp
|
||||
{
|
||||
let ret = episodes_regexp.en;
|
||||
|
||||
if (config.crlang in episodes_regexp)
|
||||
{
|
||||
ret = episodes_regexp[config.crlang];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import Promise = require('bluebird');
|
||||
import uuid = require('uuid');
|
||||
import path = require('path');
|
||||
import fs = require('fs-extra');
|
||||
import languages = require('./languages');
|
||||
import log = require('./log');
|
||||
|
||||
import { RequestPromise } from 'request-promise';
|
||||
@@ -111,6 +112,22 @@ function checkIfUserIsAuth(config: IConfig, done: (err: Error) => void): void
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
|
||||
/* As we are here, try to detect which locale CR tell us */
|
||||
const localeRE = /LOCALE = "([a-zA-Z]+)",/g;
|
||||
const locale = localeRE.exec($('script').text())[1];
|
||||
const countryCode = languages.localeToCC(locale);
|
||||
|
||||
if (config.crlang === undefined)
|
||||
{
|
||||
log.info('No locale set. Setting to the one reported by CR: "' + countryCode + '"');
|
||||
config.crlang = countryCode;
|
||||
}
|
||||
else if (config.crlang !== countryCode)
|
||||
{
|
||||
log.warn('Crunchy is configured for locale "' + config.crlang + '" but CR report "' + countryCode + '" (LOCALE = ' + locale + ')');
|
||||
log.warn('Check if it is correct or rerun (once) with "-l ' + countryCode + '" to correct.');
|
||||
}
|
||||
|
||||
/* Check if auth worked */
|
||||
const regexps = /ga\('set', 'dimension[5-8]', '([^']*)'\);/g;
|
||||
const dims = regexps.exec($('script').text());
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
'use strict';
|
||||
import cheerio = require('cheerio');
|
||||
import episode from './episode';
|
||||
// import fs = require('fs');
|
||||
import fs = require('fs-extra');
|
||||
import my_request = require('./my_request');
|
||||
import path = require('path');
|
||||
import url = require('url');
|
||||
import log = require('./log');
|
||||
import languages = require('./languages');
|
||||
|
||||
const persistent = '.crpersistent';
|
||||
|
||||
/**
|
||||
@@ -234,11 +235,13 @@ function pageScrape(config: IConfig, task: IConfigTask, done: (err: any, result?
|
||||
|
||||
const season_name = $(el).closest('ul').prev('a').text();
|
||||
const volume = /([0-9]+)\s*$/.exec($(el).closest('ul').prev('a').text());
|
||||
const regexp = /Episode\s+((PV )?[S0-9][\-P0-9.]*[a-fA-F]?)\s*$/i;
|
||||
const regexp = languages.get_epregexp(config);
|
||||
const episode = regexp.exec($(el).children('.series-title').text());
|
||||
const url = $(el).attr('href');
|
||||
|
||||
if (config.ignoredub && (season_name.endsWith('Dub)') || season_name.endsWith('dub)')))
|
||||
const igndub_re = languages.get_diregexp(config);
|
||||
|
||||
if (config.ignoredub && (igndub_re.exec(season_name)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user