From e3aab40a0ac45ae13384b28b27c242ff11a7c4d4 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 13 Jun 2017 12:25:00 -0300 Subject: Output to file 'Foo Bar.mp3' instead of 'Foo%20Bar.mp3' --- src/downloaders.js | 3 ++- todo.txt | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/downloaders.js b/src/downloaders.js index ad322fa..fa1f337 100644 --- a/src/downloaders.js +++ b/src/downloaders.js @@ -3,6 +3,7 @@ const fetch = require('node-fetch') const promisifyProcess = require('./promisify-process') const tempy = require('tempy') const path = require('path') +const sanitize = require('sanitize-filename') const { spawn } = require('child_process') const { promisify } = require('util') @@ -12,7 +13,7 @@ const writeFile = promisify(fs.writeFile) function makeHTTPDownloader() { return function(arg) { const dir = tempy.directory() - const out = dir + '/' + path.basename(arg) + const out = dir + '/' + sanitize(decodeURIComponent(path.basename(arg))) return fetch(arg) .then(response => response.buffer()) diff --git a/todo.txt b/todo.txt index bbb23f2..439181b 100644 --- a/todo.txt +++ b/todo.txt @@ -128,3 +128,10 @@ TODO: Let playlist filter match things lowercase. '72 Minutes Of Fame' should best to prioritize a case-sensitive match before a non-case-sensitive one. Given the input 'FoObAR', prioritize 'FoObAR' over 'Foobar'.) (Done!) + +TODO: Figure out why written track files (when using HTTP downloader) are + URL-encoded. It's probably writing a file based on the href-file name, + rather than the title. That's alright, but maybe we should URL-decode + and then sanitize the href-file name, so that we get 'Foo Bar.mp3' + instead of 'Foo%20Bar.mp3'. + (Done!) -- cgit 1.3.0-6-gf8a5