ytdl-core
Advanced tools
Comparing version 0.7.16 to 0.7.17
@@ -6,3 +6,3 @@ var urlParse = require('url').parse; | ||
var stream = ytdl('https://www.youtube.com/watch?v=2UBFIhS1YBk', { | ||
request: function(url, callback) { | ||
request: function(url, options, callback) { | ||
var parsed = urlParse(url); | ||
@@ -9,0 +9,0 @@ return http.get({ |
@@ -212,3 +212,6 @@ var qs = require('querystring'); | ||
* - http://www.youtube.com/watch?v=VIDEO_ID | ||
* - http://m.youtube.com/watch?v=VIDEO_ID | ||
* - http://youtu.be/VIDEO_ID | ||
* - http://www.youtube.com/v/VIDEO_ID | ||
* - http://www.youtube.com/embed/VIDEO_ID | ||
* | ||
@@ -219,5 +222,8 @@ * @param {String} link | ||
exports.getVideoID = function(link) { | ||
var linkParsed = url.parse(link, true); | ||
var id = linkParsed.hostname === 'youtu.be' ? | ||
linkParsed.pathname.slice(1) : linkParsed.query.v; | ||
var parsed = url.parse(link, true); | ||
var id = parsed.query.v; | ||
if (parsed.hostname === 'youtu.be' || !id) { | ||
var s = parsed.pathname.split('/'); | ||
id = s[s.length - 1]; | ||
} | ||
if (!id) { | ||
@@ -224,0 +230,0 @@ throw new Error('No video id found: ' + link); |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.7.16", | ||
"version": "0.7.17", | ||
"repository": { | ||
@@ -12,0 +12,0 @@ "type": "git", |
@@ -229,2 +229,6 @@ var util = require('../lib/util'); | ||
assert(id, 'VIDEO_ID'); | ||
id = util.getVideoID('http://youtube.com/v/VIDEO_ID'); | ||
assert(id, 'VIDEO_ID'); | ||
id = util.getVideoID('http://youtube.com/embed/VIDEO_ID'); | ||
assert(id, 'VIDEO_ID'); | ||
}); | ||
@@ -231,0 +235,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11945246
52
57506