From 504419b116a7cb3fcdc07ce27695475b40e51b4e Mon Sep 17 00:00:00 2001 From: David Smusz Date: Thu, 16 Jan 2020 22:50:11 +0100 Subject: [PATCH] fix: args check --- lib/youtube-dl.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/youtube-dl.js b/lib/youtube-dl.js index 74231d0..740db1b 100644 --- a/lib/youtube-dl.js +++ b/lib/youtube-dl.js @@ -46,10 +46,10 @@ function processData (data, args, options, stream) { if (options && options.start > 0 && options.end > 0) { headers.Range = 'bytes=' + options.start + '-' + options.end } else { - headers.Range = 'bytes=0-' + item.filesize - } + headers.Range = 'bytes=0-' + item.filesize + } - const proxyArgIndex = args.indexOf('--proxy') + const proxyArgIndex = (args && args.indexOf('--proxy')) || -1 const req = request({ url: item.url, headers: headers, @@ -101,7 +101,9 @@ const ytdl = (module.exports = function (videoUrl, args, options) { } ytdl.getInfo(videoUrl, args, options, function getInfo (err, data) { - return err ? stream.emit('error', err) : processData(data, args, options, stream) + return err + ? stream.emit('error', err) + : processData(data, args, options, stream) }) return stream