diff options
Diffstat (limited to 'general-util.js')
-rw-r--r-- | general-util.js | 17 |
1 files changed, 17 insertions, 0 deletions
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) + } +} |