Browse Source

added custom filenames

ssttevee 7 years ago
parent
commit
4dc90aeb00
3 changed files with 13 additions and 1 deletions
  1. 1 0
      src/batch.ts
  2. 11 1
      src/episode.ts
  3. 1 0
      src/interface/IConfig.d.ts

+ 1 - 0
src/batch.ts

@@ -149,6 +149,7 @@ function parse(args: string[]): IConfigLine
     .option('-f, --format <s>', 'The subtitle format. (Default: ass)')
     .option('-o, --output <s>', 'The output path.')
     .option('-s, --series <s>', 'The series override.')
+    .option('-n, --filename <s>', 'The name override.')
     .option('-t, --tag <s>', 'The subgroup. (Default: CrunchyRoll)')
     .parse(args);
 }

+ 11 - 1
src/episode.ts

@@ -196,7 +196,17 @@ function name(config: IConfig, page: IEpisodePage, series: string, extra: string
   const volume = (volumeNum < 10 ? '0' : '') + page.volume;
   const tag = config.tag || 'CrunchyRoll';
 
-  return series + ' - s' + volume + 'e' + episode + ' - [' + tag + ']' + extra;
+  if (!config.filename) {
+    return page.series + ' - s' + volume + 'e' + episode + ' - [' + tag + ']' + extra;
+  }
+
+  return config.filename
+      .replace(/{EPISODE_ID}/g, page.id.toString())
+      .replace(/{EPISODE_NUMBER}/g, episode)
+      .replace(/{SEASON_NUMBER}/g, volume)
+      .replace(/{VOLUME_NUMBER}/g, volume)
+      .replace(/{SERIES_TITLE}/g, series)
+      .replace(/{TAG}/g, tag) + extra;
 }
 
 /**

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

@@ -12,5 +12,6 @@ interface IConfig {
   format?: string;
   output?: string;
   series?: string;
+  filename?: string;
   tag?: string;
 }