« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/play.js')
-rwxr-xr-xsrc/play.js21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/play.js b/src/play.js
index d5df591..158c887 100755
--- a/src/play.js
+++ b/src/play.js
@@ -20,29 +20,16 @@ const {
 } = require('./playlist-utils')
 
 const {
+  downloadPlaylistFromOptionValue
+} = require('./general-util')
+
+const {
   compileKeybindings, getComboForCommand, stringifyCombo
 } = require('./keybinder')
 
 const readFile = promisify(fs.readFile)
 const writeFile = promisify(fs.writeFile)
 
-function downloadPlaylistFromURL(url) {
-  return fetch(url).then(res => res.text())
-}
-
-function downloadPlaylistFromLocalPath(path) {
-  return readFile(path)
-}
-
-function downloadPlaylistFromOptionValue(arg) {
-  // TODO: Verify things!
-  if (arg.startsWith('http://') || arg.startsWith('https://')) {
-    return downloadPlaylistFromURL(arg)
-  } else {
-    return downloadPlaylistFromLocalPath(arg)
-  }
-}
-
 function clearConsoleLine() {
   process.stdout.write('\x1b[1K\r')
 }