You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
888 B
JavaScript
31 lines
888 B
JavaScript
'use strict';
|
|
|
|
const Promise = require("bluebird");
|
|
const childProcess = Promise.promisifyAll(require("child_process"));
|
|
const playlist = require("./playlist");
|
|
|
|
Promise.try(() => {
|
|
return playlist("https://media.pixelbar.nl/getjson.php");
|
|
}).then((playlist) => {
|
|
playlist.on("track", (track) => {
|
|
Promise.try(() => {
|
|
console.log("NOW PLAYING:", track.media_title);
|
|
|
|
return new Promise((resolve, reject) => {
|
|
let player = childProcess.spawn("mpv", ["--no-video", "--end='10:00'", track.media_url]);
|
|
|
|
player.stdout.pipe(process.stdout);
|
|
player.stderr.pipe(process.stderr);
|
|
|
|
player.on("exit", () => {
|
|
resolve();
|
|
});
|
|
});
|
|
}).then(() => {
|
|
playlist.reportFinished();
|
|
});
|
|
});
|
|
|
|
playlist.reportFinished();
|
|
})
|