From 7926b2fd9af38ceeb95bbfb7791cc9009301eaba Mon Sep 17 00:00:00 2001 From: Godzil Date: Mon, 13 Apr 2020 20:09:30 +0100 Subject: [PATCH] Make the code compile again. --- src/batch.ts | 2 +- src/episode.ts | 20 ++++++++++---------- src/interface/AuthError.d.ts | 2 ++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/batch.ts b/src/batch.ts index b26607d..6828428 100644 --- a/src/batch.ts +++ b/src/batch.ts @@ -366,6 +366,6 @@ function parse(args: string[]): IConfigLine .option('--verbose', 'Make tool verbose') .option('--debug', 'Create a debug file. Use only if requested!') .option('--rebuildcrp', 'Rebuild the crpersistant file.') - .option('--retry ', 'Number or time to retry fetching an episode.', 5) + .option('--retry ', 'Number or time to retry fetching an episode.', '5') .parse(args); } diff --git a/src/episode.ts b/src/episode.ts index 6774701..ecffa25 100644 --- a/src/episode.ts +++ b/src/episode.ts @@ -72,7 +72,7 @@ function sanitiseFileName(str: string) /** * Downloads the subtitle and video. */ -function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, done: (err: Error, ign: boolean) => void) +function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, done: (err: Error | string, ign: boolean) => void) { const serieFolder = sanitiseFileName(config.series || page.series); @@ -109,14 +109,9 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d return done(null, true); } - mkdirp(path.dirname(filePath), (errM: Error) => + const ret = mkdirp(path.dirname(filePath)); + if (ret) { - if (errM) - { - log.dispEpisode(fileName, 'Error...', true); - return done(errM, false); - } - log.dispEpisode(fileName, 'Fetching...', false); downloadSubtitle(config, player, filePath, (errDS) => { @@ -164,13 +159,18 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d done(null, true); } }); - }); + } + else + { + log.dispEpisode(fileName, 'Error creating folder \'" + filePath + "\'...', true); + return done('Cannot create folder', false); + } } /** * Saves the subtitles to disk. */ -function downloadSubtitle(config: IConfig, player: IEpisodePlayer, filePath: string, done: (err?: Error) => void) +function downloadSubtitle(config: IConfig, player: IEpisodePlayer, filePath: string, done: (err?: Error | string) => void) { const enc = player.subtitle; diff --git a/src/interface/AuthError.d.ts b/src/interface/AuthError.d.ts index 3266b62..666e16c 100644 --- a/src/interface/AuthError.d.ts +++ b/src/interface/AuthError.d.ts @@ -1,3 +1,5 @@ interface IAuthError extends Error { + name: string; + message: string; authError: boolean; }