Browse Source

Better filename forbidden character handling
Logs are a bit better

Godzil 1 year ago
parent
commit
53f0a9462a
2 changed files with 6 additions and 5 deletions
  1. 4 3
      src/episode.ts
  2. 2 2
      src/log.ts

+ 4 - 3
src/episode.ts

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

+ 2 - 2
src/log.ts

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