« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/downloaders.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/downloaders.js b/src/downloaders.js
index 138b2d6..f5efa3e 100644
--- a/src/downloaders.js
+++ b/src/downloaders.js
@@ -111,8 +111,7 @@ function makePowerfulDownloader(downloader, maxAttempts = 5) {
 }
 
 async function makeConverter(
-  converterCommand = null, exportExtension = 'wav',
-  converterOptions = ['-i', '$in', '$out']
+  converterCommand = null, exportExtension = 'wav'
 ) {
   if (converterCommand === null) {
     throw new Error(
@@ -120,7 +119,14 @@ async function makeConverter(
     )
   }
 
-  return function(converterOptions = ['-i', '$in', '$out']) {
+  return function(converterOptions = null) {
+    if (converterOptions === null) {
+      if (['ffmpeg', 'avconv'].includes(converterCommand)) {
+        converterOptions = ['-i', '$in', '$out']
+      } else if (converterCommand === 'cp') {
+        converterOptions = ['$in', '$out']
+      }
+    }
     return async function(inFile) {
       const base = path.basename(inFile, path.extname(inFile))
       const tempDir = tempy.directory()