Better filename forbidden character handling

Logs are a bit better
This commit is contained in:
Godzil 2017-09-16 22:51:49 +01:00
parent 10d71944d9
commit 53f0a9462a
2 changed files with 6 additions and 5 deletions

View File

@ -65,8 +65,7 @@ function fileExist(path: string)
function sanitiseFileName(str: string)
{
return str.replace('/', '_').replace('\'', '_').replace(':', '_').replace('?', '_')
.replace('*', '_').replace('\"', '_').replace('<', '_').replace('>', '_');
return str.replace(/[\/':\?\*"<>\.]/g, '_');
}
/**
@ -102,6 +101,7 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d
return done(errM, false);
}
log.dispEpisode(fileName, 'Fetching...', false);
downloadSubtitle(config, player, filePath, (errDS) =>
{
if (errDS)
@ -112,7 +112,7 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d
const now = Date.now();
if (player.video.file !== undefined)
{
log.dispEpisode(fileName, 'Fetching...', false);
log.dispEpisode(fileName, 'Fetching video...', false);
downloadVideo(config, page, player, filePath, (errDV) =>
{
if (errDV)
@ -127,6 +127,7 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d
const isSubtited = Boolean(player.subtitle);
log.dispEpisode(fileName, 'Merging...', false);
video.merge(config, isSubtited, player.video.file, filePath, player.video.mode, (errVM) =>
{
if (errVM)

View File

@ -28,10 +28,10 @@ export function warn(str: string)
export function dispEpisode(name: string, status: string, addNL: boolean)
{
/* Do fancy output */
process.stdout.write(' \x1B[1;33m> \x1B[37m' + name + '\x1B[0m : \x1B[33m' + status + '\x1B[0m\x1B[0G');
process.stdout.write('\x1B[K \x1B[1;33m> \x1B[37m' + name + '\x1B[0m : \x1B[33m' + status + '\x1B[0m\x1B[0G');
if (addNL)
{
console.log('');
}
}
}