From 6055638558a345904b41467839191a7143862d25 Mon Sep 17 00:00:00 2001 From: Florrie Date: Mon, 4 Jun 2018 21:27:18 -0300 Subject: Smart playlists Basically directly pulled from http-music. Want to make a nice UI for this eventually ("opening playlist..." popup dialog), but not for now. --- general-util.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'general-util.js') diff --git a/general-util.js b/general-util.js index 35e1103..879219d 100644 --- a/general-util.js +++ b/general-util.js @@ -46,3 +46,20 @@ module.exports.killProcess = async function(proc) { proc.kill() } } + +function downloadPlaylistFromURL(url) { + return fetch(url).then(res => res.text()) +} + +function downloadPlaylistFromLocalPath(path) { + return readFile(path).then(buf => buf.toString()) +} + +module.exports.downloadPlaylistFromOptionValue = function(arg) { + // TODO: Verify things! + if (arg.startsWith('http://') || arg.startsWith('https://')) { + return downloadPlaylistFromURL(arg) + } else { + return downloadPlaylistFromLocalPath(arg) + } +} -- cgit 1.3.0-6-gf8a5