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

Commit

Permalink
Fix the broken Host HTTP Header for Dailymotion && Fix Test
Browse files Browse the repository at this point in the history
  • Loading branch information
ngotchac committed Apr 18, 2015
1 parent 484d1c3 commit 9657b8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,32 @@ var subsRegex = /--write-sub|--write-srt|--srt-lang|--all-subs/;
/**
* Downloads a video.
*
* @param {String} url
* @param {String} videoUrl
* @param {!Array.<String>} args
* @param {!Object} options
*/
var ytdl = module.exports = function(url, args, options) {
var ytdl = module.exports = function(videoUrl, args, options) {
var stream = streamify({
superCtor: http.ClientResponse,
readable: true,
writable: false
});

ytdl.getInfo(url, args, options, function(err, data) {
ytdl.getInfo(videoUrl, args, options, function(err, data) {
if (err) {
stream.emit('error', err);
return;
}

var item = (!data.length) ? data : data.shift();

var req = request(item.url);
var req = request({
url: item.url,
headers: {
'Host': url.parse(item.url).hostname
}
});

req.on('response', function(res) {
if (res.statusCode !== 200) {
stream.emit('error', new Error('status code ' + res.statusCode));
Expand Down
2 changes: 1 addition & 1 deletion test/getFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var assert = require('assert');
var youtubevideo = 'http://www.youtube.com/watch?v=0k2Zzkw_-0I';
var mixcloudvideo =
'http://www.mixcloud.com/' +
'TheBloodyBeetroots/sbcr-dj-mix-october-2014/';
'ItchFM/mr-dex-the-dex-files-ep-84/';

vows.describe('getFormats').addBatch({
'from a video': {
Expand Down

0 comments on commit 9657b8c

Please sign in to comment.