Created
May 25, 2017 15:13
-
-
Save cacheflow/39e61abdf8ba024162c31cf45e0a9e7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const ytdl = require('./lib/index'); | |
ytdl('https://youtu.be/fxlbIS8CoW8') | |
.pipe(fs.createWriteStream('video.flv')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in util | |
case 'baseline': | |
format = formats.find(function(format) {return format.profile == 'baseline'}) | |
break; | |
request(url, {}, function(err, res, body) { | |
if (err) { | |
format = util.chooseFormat(info.formats, {quality: 'baseline'}); | |
url = format.url | |
} | |
if (format.live) { | |
var req = m3u8stream(url, { | |
chunkReadahead: +info.live_chunk_readahead, | |
requestOptions: options.requestOptions, | |
}); | |
req.on('error', stream.emit.bind(stream, 'error')); | |
stream.destroy = req.end.bind(req); | |
req.pipe(stream); | |
} else { | |
if (options.begin) { | |
url += '&begin=' + util.fromHumanTime(options.begin); | |
} | |
doDownload(stream, url, options, { | |
trys: options.retries || 5, | |
range: { | |
start: options.range && options.range.start ? options.range.start : 0, | |
end: options.range && options.range.end ? options.range.end : -1, | |
}, | |
downloaded: 0, | |
}); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment