« get me outta code hell

Generally optimize downloads (less file copying) - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/loop-play.js
diff options
context:
space:
mode:
authorliam4 <towerofnix@gmail.com>2017-06-04 17:09:47 -0300
committerliam4 <towerofnix@gmail.com>2017-06-04 17:09:47 -0300
commit170b9091f662e082a410128644b63ae787747c94 (patch)
tree402ba316240ec95dd13e2e2f58290d4a96a25718 /src/loop-play.js
parent9fb775446f151b492f17bd42b757b958f5ea3fa0 (diff)
Generally optimize downloads (less file copying)
Basically all we do is let downloaders specify the output file,
rather than be forced to download or copy into a specific given
file. Since avconv/convert automatically gets us the displayed
file name we want anyways (shown in play), this doesn't change
anything visible to the user, but does make things faster.
Diffstat (limited to 'src/loop-play.js')
-rw-r--r--src/loop-play.js5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/loop-play.js b/src/loop-play.js
index 50bca80..5205025 100644
--- a/src/loop-play.js
+++ b/src/loop-play.js
@@ -30,11 +30,10 @@ module.exports = async function loopPlay(picker, downloader, playArgs = []) {
     const [ title, downloaderArg ] = picked
     console.log(`Downloading ${title}..\nDownloader arg: ${downloaderArg}`)
 
+    const downloadFile = await downloader(downloaderArg)
+
     const tempDir = tempy.directory()
     const wavFile = tempDir + `/.${sanitize(title)}.wav`
-    const downloadFile = tempDir + '/.dl-' + path.basename(downloaderArg)
-
-    await downloader(downloaderArg, downloadFile)
 
     try {
       await convert(downloadFile, wavFile)