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

Commit

Permalink
Fix - Incorrect youtube video URL
Browse files Browse the repository at this point in the history
match possible long and short youtube urls throw only if none match
  • Loading branch information
przemyslawpluta committed Feb 12, 2014
1 parent f4498fa commit 28dd461
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,19 @@ exports.download = function(urladdr, dest, args) {
}
args.push(urladdr);

// Get ID from urladdr.
var query = url.parse(urladdr, true).query;
var id = query.v || '';
if (!id) {
throw new TypeError('Incorrect video URL');
// soft check for youtube video
var isYouToube = urladdr.match(/(youtube|youtu.be)/), details, query, id;

if (isYouToube) {
details = url.parse(urladdr, true);
query = details.query;
pathname = details.pathname.slice(1);
// Get possible IDs from urladdr.
id = query.v || pathname;
}

if (!isYouToube || !id) {
throw new TypeError('Incorrect youtube video URL');
}

var speed = [];
Expand Down

0 comments on commit 28dd461

Please sign in to comment.