« get me outta code hell

Make some error handling for YouTube downloads - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/loop-play.js
diff options
context:
space:
mode:
authorliam4 <towerofnix@gmail.com>2017-07-21 22:27:34 -0300
committerliam4 <towerofnix@gmail.com>2017-07-21 22:27:34 -0300
commitb6e90e8f380569803b9a83f8997159b34d64e501 (patch)
treeb2ac9c18415301e90dc9980255ea48e54a87b9f7 /src/loop-play.js
parent13ec7f5c5408c787e8e424a79ffeea281b044b6f (diff)
Make some error handling for YouTube downloads
Diffstat (limited to 'src/loop-play.js')
-rw-r--r--src/loop-play.js26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/loop-play.js b/src/loop-play.js
index 884d3cb..8fdbdf3 100644
--- a/src/loop-play.js
+++ b/src/loop-play.js
@@ -95,8 +95,11 @@ class PlayController {
 
     while (this.nextTrack) {
       this.currentTrack = this.nextTrack
+
       await Promise.all([
-        this.playFile(nextFile),
+        // If the downloader returns false, the file failed to download; that
+        // means we'll just skip this track and wait for the next.
+        nextFile !== false ? this.playFile(nextFile) : Promise.resolve(),
         downloadNext()
       ])
     }
@@ -115,27 +118,6 @@ class PlayController {
     }
   }
 
-  async old_loopPlay() {
-    // Playing music in a loop isn't particularly complicated; essentially, we
-    // just want to keep picking and playing tracks until none is picked.
-
-    let nextTrack = await this.picker()
-
-    await this.downloadManager.download(getDownloaderFor(nextTrack), nextTrack)
-
-    let downloadNext
-
-    while (nextTrack) {
-      this.currentTrack = nextTrack
-
-      this.downloadManager.download(getDownloaderFor(nextTrack), nextTrack)
-
-      await this.playFile(nextTrack[1])
-
-      nextTrack = await this.picker()
-    }
-  }
-
   playFile(file) {
     this.fifo = new FIFO()
     this.process = spawn('mpv', [