Browse Source

Add an experimental feature: ignoring episodes from season that end with 'dub)' as they are dubbed seasons.

Godzil 5 years ago
parent
commit
ed233de565
5 changed files with 15 additions and 1 deletions
  1. 1 0
      src/batch.ts
  2. 1 0
      src/config.ts
  3. 1 0
      src/interface/IConfig.d.ts
  4. 1 0
      src/interface/ISeriesEpisode.d.ts
  5. 11 1
      src/series.ts

+ 1 - 0
src/batch.ts

@@ -344,6 +344,7 @@ function parse(args: string[]): IConfigLine
     .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('-t, --tag <s>', 'The subgroup.', 'CrunchyRoll')
     .option('-r, --resolution <s>', 'The video resolution. (valid: 360, 480, 720, 1080)', '1080')

+ 1 - 0
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, '  '));
 }

+ 1 - 0
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;

+ 1 - 0
src/interface/ISeriesEpisode.d.ts

@@ -1,6 +1,7 @@
 interface ISeriesEpisode {
   address: string;
   episode: string;
+  seasonName: string;
   volume: number;
   retry: number;
 }

+ 11 - 1
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?');