9 Commits

Author SHA1 Message Date
Godzil
e5c4c08e66 1.4.4 2018-08-27 16:46:59 +01:00
Godzil
2b201b0785 Fix #94 2018-08-27 13:16:22 +01:00
Godzil
fdf5805911 Fix for #88 2018-08-27 13:11:06 +01:00
Godzil
9191075f48 Fix for #92 when the version server is not answering properly 2018-08-27 13:08:01 +01:00
Godzil
9f73e4f865 Update `ignoredub` to support more form
(and also make it work with multiple languages)
2018-08-17 00:56:50 +01:00
Manoël Trapier
1f20e028e1 Merge pull request #87 from TheDammedGamer/master
Filtering out Pipe Symbol in file names
2018-08-13 15:36:35 +01:00
Liam Townsend
da0fb17015 Filtering out Pipe Symbol in file names
updated sanitiseFileName to include the pipe symbol as this character is not allowed on windows, the error thast it currently throws is: {"errno":-4058,"code":"ENOENT","syscall":"open","path":"K:\\MediaDwn\\Is It Wrong to Try to Pick Up Girls in a Dungeon_\\Is It Wrong to Try to Pick Up Girls in a Dungeon_ - s01e01 - Bell Cranel | Adventurer - [CrunchyRoll].ass"}
2018-08-13 15:25:06 +01:00
Godzil
2aa71832b3 1.4.3 2018-08-11 20:50:02 +01:00
Godzil
876def4392 Add code to check what langage CR is serving the page, and try to adapt
some regexp to that. The langage can be forced by the user

Fix #1 and Fix #76
2018-08-11 20:42:12 +01:00
9 changed files with 116 additions and 16 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "crunchy",
"version": "1.4.2",
"version": "1.4.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -15,7 +15,7 @@
"engines": {
"node": ">=5.0"
},
"version": "1.4.2",
"version": "1.4.4",
"bin": {
"crunchy": "./bin/crunchy",
"crunchy.sh": "./bin/crunchy.sh"

View File

@@ -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')

View File

@@ -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) =>

View File

@@ -66,7 +66,7 @@ function fileExist(path: string)
function sanitiseFileName(str: string)
{
return str.replace(/[\/':\?\*"<>\\\.]/g, '_');
return str.replace(/[\/':\?\*"<>\\\.\|]/g, '_');
}
/**

View File

@@ -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
View 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;
}

View File

@@ -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());

View File

@@ -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;
}