« get me outta code hell

Better download file naming - 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-01 09:38:36 -0300
committerliam4 <towerofnix@gmail.com>2017-06-01 09:38:56 -0300
commit671fc02d4fb26db0a5c3f83845eb46da73b08548 (patch)
treef682d49634b9d9277ac58ffa7dfae276ca77eea4 /src/loop-play.js
parentbfe7a21c2734ff6b9f9b993d1bc114e901e926f1 (diff)
Better download file naming
Diffstat (limited to 'src/loop-play.js')
-rw-r--r--src/loop-play.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/loop-play.js b/src/loop-play.js
index 8c81680..0a4b291 100644
--- a/src/loop-play.js
+++ b/src/loop-play.js
@@ -6,8 +6,9 @@ const tempy = require('tempy')
 const { spawn } = require('child_process')
 const { promisify } = require('util')
 const fetch = require('node-fetch')
-const sanitize = require('sanitize-filename')
+const path = require('path')
 const promisifyProcess = require('./promisify-process')
+const sanitize = require('sanitize-filename')
 
 const writeFile = promisify(fs.writeFile)
 
@@ -28,9 +29,9 @@ module.exports = async function loopPlay(fn) {
     const [ title, href ] = picked
     console.log(`Downloading ${title}..\n${href}`)
 
-    const wavDir = tempy.directory()
-    const wavFile = wavDir + `/.${sanitize(title)}.wav`
-    const downloadFile = tempy.file()
+    const tempDir = tempy.directory()
+    const wavFile = tempDir + `/.${sanitize(title)}.wav`
+    const downloadFile = tempDir + '/.dl-' + path.basename(href)
 
     const res = await fetch(href)
     const buffer = await res.buffer()