mirror of https://github.com/icedream/ts3bot.git
Use youtube-dl to resolve URLs if possible.
First try --format=bestaudio, if that fails try --format=best and if that fails as well, just pass the URL as-is to VLC. Very fault tolerant and silently ignores errors (except for letting it show up in the logs)...develop
parent
ab3e66ae8f
commit
a5dbbb631b
83
package.json
83
package.json
|
@ -1,43 +1,44 @@
|
||||||
{
|
{
|
||||||
"name": "ts3bot",
|
"name": "ts3bot",
|
||||||
"version": "0.2.0",
|
"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.",
|
"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",
|
"main": "app.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"teamspeak",
|
"teamspeak",
|
||||||
"teamspeak3",
|
"teamspeak3",
|
||||||
"ts3",
|
"ts3",
|
||||||
"bot",
|
"bot",
|
||||||
"ts3bot",
|
"ts3bot",
|
||||||
"teamspeak3bot",
|
"teamspeak3bot",
|
||||||
"music",
|
"music",
|
||||||
"playback",
|
"playback",
|
||||||
"audio",
|
"audio",
|
||||||
"video",
|
"video",
|
||||||
"media",
|
"media",
|
||||||
"musicbot"
|
"musicbot"
|
||||||
],
|
],
|
||||||
"author": "Carl Kittelberger <icedream2k9@die-optimisten.net>",
|
"author": "Carl Kittelberger <icedream2k9@die-optimisten.net>",
|
||||||
"license": "GPL-3.0+",
|
"license": "GPL-3.0+",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.13.3",
|
"express": "^4.13.3",
|
||||||
"iced-coffee-script": "^108.0.8",
|
"iced-coffee-script": "^108.0.8",
|
||||||
"merge": "^1.2.0",
|
"merge": "^1.2.0",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"nconf": "^0.7.2",
|
"nconf": "^0.7.2",
|
||||||
"npm-which": "^2.0.0",
|
"npm-which": "^2.0.0",
|
||||||
"password-generator": "^2.0.1",
|
"password-generator": "^2.0.1",
|
||||||
"querystring": "^0.2.0",
|
"querystring": "^0.2.0",
|
||||||
"request": "^2.61.0",
|
"request": "^2.61.0",
|
||||||
"simple-ini": "^1.0.3",
|
"simple-ini": "^1.0.3",
|
||||||
"sqlite3": "^3.1.0",
|
"sqlite3": "^3.1.0",
|
||||||
"stream-splitter": "^0.3.2",
|
"stream-splitter": "^0.3.2",
|
||||||
"string.prototype.startswith": "^0.2.0",
|
"string.prototype.startswith": "^0.2.0",
|
||||||
"sync": "^0.2.5",
|
"sync": "^0.2.5",
|
||||||
"valid-url": "^1.0.9",
|
"valid-url": "^1.0.9",
|
||||||
"vlc-api": "0.0.0",
|
"vlc-api": "0.0.0",
|
||||||
"which": "^1.1.2",
|
"which": "^1.1.2",
|
||||||
"winston": "^1.0.1",
|
"winston": "^1.0.1",
|
||||||
"xvfb": "git://github.com/icedream/node-xvfb.git"
|
"xvfb": "git://github.com/icedream/node-xvfb.git",
|
||||||
}
|
"youtube-dl": "^1.10.5"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ Socket = net.Socket
|
||||||
getLogger = require "../logger"
|
getLogger = require "../logger"
|
||||||
config = require "../config"
|
config = require "../config"
|
||||||
log = getLogger "API"
|
log = getLogger "API"
|
||||||
|
youtubedl = require "youtube-dl"
|
||||||
#PulseAudio = require "pulseaudio"
|
#PulseAudio = require "pulseaudio"
|
||||||
isValidUrl = (require "valid-url").isWebUri
|
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
|
log.warn "VLC API returned an error when trying to empty", err
|
||||||
return
|
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
|
if err
|
||||||
vlc.status.empty()
|
vlc.status.empty()
|
||||||
res.status(503).send("Something went wrong")
|
res.status(503).send("Something went wrong")
|
||||||
log.warn "VLC API returned an error when trying to play", err
|
log.warn "VLC API returned an error when trying to play", err
|
||||||
return
|
return
|
||||||
|
|
||||||
res.send("OK")
|
res.send JSON.stringify info
|
||||||
|
|
||||||
app.get "/stop", (req, res) =>
|
app.get "/stop", (req, res) =>
|
||||||
if not req.query.uid
|
if not req.query.uid
|
||||||
|
|
Loading…
Reference in New Issue