From 07c9f7622567d822670c1021280c4dba4d161794 Mon Sep 17 00:00:00 2001 From: liam4 Date: Wed, 26 Jul 2017 12:43:44 -0300 Subject: Let downloader be specified manually, per-track (e.g. use youtube-dl for non-YT links) --- src/loop-play.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/loop-play.js') diff --git a/src/loop-play.js b/src/loop-play.js index b0bb4dd..9328073 100644 --- a/src/loop-play.js +++ b/src/loop-play.js @@ -5,7 +5,10 @@ const { spawn } = require('child_process') const FIFO = require('fifo-js') const EventEmitter = require('events') -const { getDownloaderFor, makeConverterDownloader } = require('./downloaders') +const { + getDownloaderFor, makeConverterDownloader, + byName: downloadersByName +} = require('./downloaders') const { getItemPathString } = require('./playlist-utils') const promisifyProcess = require('./promisify-process') @@ -114,7 +117,22 @@ class PlayController { if (picked === null) { return null } else { - let downloader = getDownloaderFor(picked.downloaderArg) + let downloader + + if (picked.downloader) { + downloader = downloadersByName[picked.downloader]() + + if (!downloader) { + console.error( + `Invalid downloader for track ${picked.name}:`, downloader + ) + + return false + } + } else { + downloader = getDownloaderFor(picked.downloaderArg) + } + downloader = makeConverterDownloader(downloader, 'wav') this.downloadController.download(downloader, picked.downloaderArg) return picked -- cgit 1.3.0-6-gf8a5