Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
fix: args check
Browse files Browse the repository at this point in the history
  • Loading branch information
David Smusz authored and David Smusz committed Jan 16, 2020
1 parent dd3d7ee commit 504419b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 504419b

Please sign in to comment.