Bot crash if youtube-dl error
Delivator opened this issue · comments
The bot crashes, when the youtube-dl library can't download a video.
Example:
[2017-11-13 21:52:08] [YTDL] Downloading file "https://www.youtube.com/watch?v=l_kBZuXmk6c" to ".cache/aaf4b5b336fcabe9d364d5b427bc55d9"
events.js:182
throw er; // Unhandled 'error' event
^
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at parseInfo (/home/delivator/discord-bot/node_modules/youtube-dl/lib/youtube-dl.js:228:21)
at Array.map (<anonymous>)
at done (/home/delivator/discord-bot/node_modules/youtube-dl/lib/youtube-dl.js:290:25)
at done (/home/delivator/discord-bot/node_modules/youtube-dl/lib/youtube-dl.js:202:9)
at ChildProcess.exithandler (child_process.js:278:5)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:927:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
or
[2017-11-13 21:49:43] [YTDL] Downloading file "https://www.youtube.com/watch?v=l_kBZuXmk6" to ".cache/6e2e828ad6e58676d4d6db18026d3f9f"
events.js:182
throw er; // Unhandled 'error' event
^
Error: Command failed: /home/delivator/discord-bot/node_modules/youtube-dl/bin/youtube-dl --dump-json -f best -x --audio-format=mp3 http://www.youtube.com/watch?v=l_kBZuXmk6
WARNING: Assuming --restrict-filenames since file system encoding cannot encode all characters. Set the LC_ALL environment variable to fix this.
ERROR: Incomplete YouTube ID l_kBZuXmk6. URL http://www.youtube.com/watch?v=l_kBZuXmk6 looks truncated.
at ChildProcess.exithandler (child_process.js:271:12)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:927:16)
at Socket.stream.socket.on (internal/child_process.js:348:11)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at Pipe._handle.close [as _onclose] (net.js:547:12)