Merge pull request #22 from ssttevee/master

Custom filenames
This commit is contained in:
Manoël Trapier 2017-05-09 19:55:45 +01:00 committed by GitHub
commit 41f67798d6
4 changed files with 23 additions and 1 deletions

View File

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

View File

@ -196,7 +196,20 @@ 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(/{SEASON_TITLE}/g, page.season)
.replace(/{VOLUME_TITLE}/g, page.season)
.replace(/{SERIES_TITLE}/g, series)
.replace(/{EPISODE_TITLE}/g, page.title)
.replace(/{TAG}/g, tag) + extra;
}
/**
@ -238,6 +251,7 @@ function scrapePage(config: IConfig, address: string, done: (err: Error, page?:
const regexp = /\s*([^\n\r\t\f]+)\n?\s*[^0-9]*([0-9][\-0-9.]*)?,?\n?\s\s*[^0-9]*((PV )?[S0-9][P0-9.]*[a-fA-F]?)/;
const look = $('#showmedia_about_media').text();
const seasonTitle = $('span[itemprop="title"]').text();
let episodeTitle = $('#showmedia_about_name').text().replace(/[“”]/g, '');
const data = regexp.exec(look);
if (!swf || !data)
@ -248,6 +262,8 @@ function scrapePage(config: IConfig, address: string, done: (err: Error, page?:
episode: '0',
id: epId,
series: seasonTitle,
season: seasonTitle,
title: episodeTitle,
swf: swf[1],
volume: '0',
});
@ -258,6 +274,8 @@ function scrapePage(config: IConfig, address: string, done: (err: Error, page?:
episode: data[3],
id: epId,
series: data[1],
season: seasonTitle,
title: episodeTitle,
swf: swf[1],
volume: data[2] || '1',
});

View File

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

View File

@ -3,5 +3,7 @@ interface IEpisodePage {
episode: string;
series: string;
volume: string;
season: string;
title: string;
swf: string;
}