Browse Source

Update ``ignoredub`` to support more form
(and also make it work with multiple languages)

Godzil 5 years ago
parent
commit
9f73e4f865
2 changed files with 22 additions and 1 deletions
  1. 19 0
      src/languages.ts
  2. 3 1
      src/series.ts

+ 19 - 0
src/languages.ts

@@ -23,6 +23,25 @@ export function localeToCC(locale: string): string
   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,

+ 3 - 1
src/series.ts

@@ -239,7 +239,9 @@ function pageScrape(config: IConfig, task: IConfigTask, done: (err: any, result?
         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;
         }