Stop messing with the config objet
This commit is contained in:
parent
817843c40c
commit
8c1e0f2e0c
@ -71,7 +71,12 @@ export default function(args: string[], done: (err?: Error) => void)
|
||||
return done();
|
||||
}
|
||||
|
||||
series(tasksArr[i].config, tasksArr[i].address, (errin) =>
|
||||
if (config.debug)
|
||||
{
|
||||
log.dumpToDebug('Task ' + i, JSON.stringify(tasksArr[i]));
|
||||
}
|
||||
|
||||
series(config, tasksArr[i], (errin) =>
|
||||
{
|
||||
if (errin)
|
||||
{
|
||||
|
||||
@ -101,7 +101,7 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d
|
||||
|
||||
log.warn('Renaming to \'' + fileName + '\'...');
|
||||
|
||||
config.filename = fileName;
|
||||
page.filename = fileName;
|
||||
}
|
||||
|
||||
if (config.rebuildcrp)
|
||||
@ -219,11 +219,11 @@ function name(config: IConfig, page: IEpisodePage, series: string, extra: string
|
||||
const volume = (volumeNum < 10 ? '0' : '') + page.volume;
|
||||
const tag = config.tag || 'CrunchyRoll';
|
||||
|
||||
if (!config.filename) {
|
||||
if (!page.filename) {
|
||||
return page.series + ' - s' + volume + 'e' + episode + ' - [' + tag + ']' + extra;
|
||||
}
|
||||
|
||||
return config.filename
|
||||
return page.filename
|
||||
.replace(/{EPISODE_ID}/g, page.id.toString())
|
||||
.replace(/{EPISODE_NUMBER}/g, episode)
|
||||
.replace(/{SEASON_NUMBER}/g, volume)
|
||||
@ -300,6 +300,7 @@ function scrapePage(config: IConfig, address: string, done: (err: Error, page?:
|
||||
title: episodeTitle,
|
||||
swf: swf[1],
|
||||
volume: '0',
|
||||
filename: '',
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -312,6 +313,7 @@ function scrapePage(config: IConfig, address: string, done: (err: Error, page?:
|
||||
title: episodeTitle,
|
||||
swf: swf[1],
|
||||
volume: data[2] || '1',
|
||||
filename: '',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
1
src/interface/IEpisodePage.d.ts
vendored
1
src/interface/IEpisodePage.d.ts
vendored
@ -6,4 +6,5 @@ interface IEpisodePage {
|
||||
season: string;
|
||||
title: string;
|
||||
swf: string;
|
||||
filename: string;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ function fileExist(path: string)
|
||||
/**
|
||||
* Streams the series to disk.
|
||||
*/
|
||||
export default function(config: IConfig, address: string, done: (err: Error) => void)
|
||||
export default function(config: IConfig, task: IConfigTask, done: (err: Error) => void)
|
||||
{
|
||||
const persistentPath = path.join(config.output || process.cwd(), persistent);
|
||||
|
||||
@ -41,7 +41,7 @@ export default function(config: IConfig, address: string, done: (err: Error) =>
|
||||
{
|
||||
const cache = config.cache ? {} : JSON.parse(contents || '{}');
|
||||
|
||||
page(config, address, (errP, page) =>
|
||||
pageScrape(config, task, (errP, page) =>
|
||||
{
|
||||
if (errP)
|
||||
{
|
||||
@ -57,7 +57,7 @@ export default function(config: IConfig, address: string, done: (err: Error) =>
|
||||
}
|
||||
|
||||
if (i >= page.episodes.length) return done(null);
|
||||
download(cache, config, address, page.episodes[i], (errD, ignored) =>
|
||||
download(cache, config, task, page.episodes[i], (errD, ignored) =>
|
||||
{
|
||||
if (errD)
|
||||
{
|
||||
@ -77,7 +77,7 @@ export default function(config: IConfig, address: string, done: (err: Error) =>
|
||||
{
|
||||
if (config.debug)
|
||||
{
|
||||
log.dumpToDebug('series address', address);
|
||||
log.dumpToDebug('series address', task.address);
|
||||
log.dumpToDebug('series error', errD.stack || errD);
|
||||
log.dumpToDebug('series data', JSON.stringify(page));
|
||||
}
|
||||
@ -121,10 +121,10 @@ export default function(config: IConfig, address: string, done: (err: Error) =>
|
||||
* Downloads the episode.
|
||||
*/
|
||||
function download(cache: {[address: string]: number}, config: IConfig,
|
||||
baseAddress: string, item: ISeriesEpisode,
|
||||
task: IConfigTask, item: ISeriesEpisode,
|
||||
done: (err: Error, ign: boolean) => void)
|
||||
{
|
||||
const address = url.resolve(baseAddress, item.address);
|
||||
const address = url.resolve(task.address, item.address);
|
||||
|
||||
if (cache[address])
|
||||
{
|
||||
@ -146,14 +146,14 @@ function download(cache: {[address: string]: number}, config: IConfig,
|
||||
/**
|
||||
* Requests the page and scrapes the episodes and series.
|
||||
*/
|
||||
function page(config: IConfig, address: string, done: (err: Error, result?: ISeries) => void)
|
||||
function pageScrape(config: IConfig, task: IConfigTask, done: (err: Error, result?: ISeries) => void)
|
||||
{
|
||||
if (address[0] === '@')
|
||||
if (task.address[0] === '@')
|
||||
{
|
||||
log.info('Trying to fetch from ' + address.substr(1));
|
||||
log.info('Trying to fetch from ' + task.address.substr(1));
|
||||
const episodes: ISeriesEpisode[] = [];
|
||||
episodes.push({
|
||||
address: address.substr(1),
|
||||
address: task.address.substr(1),
|
||||
episode: '',
|
||||
volume: 0,
|
||||
retry: config.retry,
|
||||
@ -163,7 +163,7 @@ function page(config: IConfig, address: string, done: (err: Error, result?: ISer
|
||||
else
|
||||
{
|
||||
let episodeCount = 0;
|
||||
my_request.get(config, address, (err, result) => {
|
||||
my_request.get(config, task.address, (err, result) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
@ -179,10 +179,9 @@ function page(config: IConfig, address: string, done: (err: Error, result?: ISer
|
||||
if (!title) {
|
||||
if (config.debug)
|
||||
{
|
||||
log.dumpToDebug('inval page addr', address);
|
||||
log.dumpToDebug('inval page data', $);
|
||||
log.dumpToDebug('missing title', task.address);
|
||||
}
|
||||
return done(new Error('Invalid page.(' + address + ')'));
|
||||
return done(new Error('Invalid page.(' + task.address + ')'));
|
||||
}
|
||||
|
||||
log.info('Checking availability for ' + title);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user