From ed233de5650492a938de010b0bcfe2a77ad90330 Mon Sep 17 00:00:00 2001 From: Godzil Date: Wed, 1 Aug 2018 22:08:21 +0100 Subject: [PATCH] Add an experimental feature: ignoring episodes from season that end with 'dub)' as they are dubbed seasons. --- src/batch.ts | 1 + src/config.ts | 1 + src/interface/IConfig.d.ts | 1 + src/interface/ISeriesEpisode.d.ts | 1 + src/series.ts | 12 +++++++++++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/batch.ts b/src/batch.ts index 11ed432..dc76d75 100644 --- a/src/batch.ts +++ b/src/batch.ts @@ -344,6 +344,7 @@ function parse(args: string[]): IConfigLine .option('-f, --format ', 'The subtitle format.', 'ass') .option('-o, --output ', 'The output path.') .option('-s, --series ', 'The series name override.') + .option('--ignoredub', 'Experimental: Ignore all seasons where the title end with \'Dub)\'') .option('-n, --nametmpl ', 'Output name template', '{SERIES_TITLE} - s{SEASON_NUMBER}e{EPISODE_NUMBER} - {EPISODE_TITLE} - [{TAG}]') .option('-t, --tag ', 'The subgroup.', 'CrunchyRoll') .option('-r, --resolution ', 'The video resolution. (valid: 360, 480, 720, 1080)', '1080') diff --git a/src/config.ts b/src/config.ts index 063a035..c7e7a95 100644 --- a/src/config.ts +++ b/src/config.ts @@ -57,6 +57,7 @@ export function save(config: IConfig) tmp.verbose = undefined; tmp.debug = undefined; tmp.unlog = undefined; + tmp.ignoredub = undefined; fs.writeFileSync(configFile, JSON.stringify(tmp, null, ' ')); } \ No newline at end of file diff --git a/src/interface/IConfig.d.ts b/src/interface/IConfig.d.ts index 75eed1b..957c840 100644 --- a/src/interface/IConfig.d.ts +++ b/src/interface/IConfig.d.ts @@ -12,6 +12,7 @@ interface IConfig { series?: string; nametmpl?: string; tag?: string; + ignoredub?: boolean; resolution?: string; video_format?: string; video_quality?: string; diff --git a/src/interface/ISeriesEpisode.d.ts b/src/interface/ISeriesEpisode.d.ts index 539b0b3..3db1804 100644 --- a/src/interface/ISeriesEpisode.d.ts +++ b/src/interface/ISeriesEpisode.d.ts @@ -1,6 +1,7 @@ interface ISeriesEpisode { address: string; episode: string; + seasonName: string; volume: number; retry: number; } diff --git a/src/series.ts b/src/series.ts index 2d17830..ddcd453 100644 --- a/src/series.ts +++ b/src/series.ts @@ -181,6 +181,7 @@ function pageScrape(config: IConfig, task: IConfigTask, done: (err: any, result? episodes.push({ address: task.address.substr(1), episode: '', + seasonName: '', volume: 0, retry: config.retry, }); @@ -219,22 +220,31 @@ function pageScrape(config: IConfig, task: IConfigTask, done: (err: any, result? return; } + 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 episode = regexp.exec($(el).children('.series-title').text()); const url = $(el).attr('href'); - if ((!url) || (!episode)) { + if (config.ignoredub && (season_name.endsWith('Dub)') || season_name.endsWith('dub)'))) + { + return; + } + + if ((!url) || (!episode)) + { return; } episodeCount += 1; episodes.push({ address: url, episode: episode[1], + seasonName: season_name, volume: volume ? parseInt(volume[0], 10) : 1, retry: config.retry, }); }); + if (episodeCount === 0) { log.warn('No episodes found for ' + title + '. Could it be a movie?');