From 671fc02d4fb26db0a5c3f83845eb46da73b08548 Mon Sep 17 00:00:00 2001 From: liam4 Date: Thu, 1 Jun 2017 09:38:36 -0300 Subject: Better download file naming --- src/loop-play.js | 9 +++++---- 1 file 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() -- cgit 1.3.0-6-gf8a5