diff --git a/package.json b/package.json index 2e2c7e1..1c8aa6e 100644 --- a/package.json +++ b/package.json @@ -1,43 +1,44 @@ { - "name": "ts3bot", - "version": "0.2.0", - "description": "Allows running TeamSpeak3 as a bot for all kinds of media (local music/videos/streams/YouTube/...) without the need for a real GUI to exist.", - "main": "app.js", - "keywords": [ - "teamspeak", - "teamspeak3", - "ts3", - "bot", - "ts3bot", - "teamspeak3bot", - "music", - "playback", - "audio", - "video", - "media", - "musicbot" - ], - "author": "Carl Kittelberger ", - "license": "GPL-3.0+", - "dependencies": { - "express": "^4.13.3", - "iced-coffee-script": "^108.0.8", - "merge": "^1.2.0", - "mkdirp": "^0.5.1", - "nconf": "^0.7.2", - "npm-which": "^2.0.0", - "password-generator": "^2.0.1", - "querystring": "^0.2.0", - "request": "^2.61.0", - "simple-ini": "^1.0.3", - "sqlite3": "^3.1.0", - "stream-splitter": "^0.3.2", - "string.prototype.startswith": "^0.2.0", - "sync": "^0.2.5", - "valid-url": "^1.0.9", - "vlc-api": "0.0.0", - "which": "^1.1.2", - "winston": "^1.0.1", - "xvfb": "git://github.com/icedream/node-xvfb.git" - } + "name": "ts3bot", + "version": "0.2.0", + "description": "Allows running TeamSpeak3 as a bot for all kinds of media (local music/videos/streams/YouTube/...) without the need for a real GUI to exist.", + "main": "app.js", + "keywords": [ + "teamspeak", + "teamspeak3", + "ts3", + "bot", + "ts3bot", + "teamspeak3bot", + "music", + "playback", + "audio", + "video", + "media", + "musicbot" + ], + "author": "Carl Kittelberger ", + "license": "GPL-3.0+", + "dependencies": { + "express": "^4.13.3", + "iced-coffee-script": "^108.0.8", + "merge": "^1.2.0", + "mkdirp": "^0.5.1", + "nconf": "^0.7.2", + "npm-which": "^2.0.0", + "password-generator": "^2.0.1", + "querystring": "^0.2.0", + "request": "^2.61.0", + "simple-ini": "^1.0.3", + "sqlite3": "^3.1.0", + "stream-splitter": "^0.3.2", + "string.prototype.startswith": "^0.2.0", + "sync": "^0.2.5", + "valid-url": "^1.0.9", + "vlc-api": "0.0.0", + "which": "^1.1.2", + "winston": "^1.0.1", + "xvfb": "git://github.com/icedream/node-xvfb.git", + "youtube-dl": "^1.10.5" + } } diff --git a/services/api.iced b/services/api.iced index f92fd04..3d18085 100644 --- a/services/api.iced +++ b/services/api.iced @@ -7,6 +7,7 @@ Socket = net.Socket getLogger = require "../logger" config = require "../config" log = getLogger "API" +youtubedl = require "youtube-dl" #PulseAudio = require "pulseaudio" isValidUrl = (require "valid-url").isWebUri @@ -60,14 +61,29 @@ module.exports = class APIService extends services.Service log.warn "VLC API returned an error when trying to empty", err return - await vlc.status.play input, defer(err) + # let's give youtube-dl a shot! + await youtubedl.getInfo input, [ + "--format=bestaudio" + ], defer(err, info) + if err or not info? + await youtubedl.getInfo input, [ + "--format=best" + ], defer(err, info) + if err or not info? + info = + url: input + if not info.url? + info.url = input + info.title = input # URL as title + + await vlc.status.play info.url, defer(err) if err vlc.status.empty() res.status(503).send("Something went wrong") log.warn "VLC API returned an error when trying to play", err return - res.send("OK") + res.send JSON.stringify info app.get "/stop", (req, res) => if not req.query.uid