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
assume other video sites
  • Loading branch information
przemyslawpluta committed Feb 12, 2014
1 parent 28dd461 commit a5eeb09
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,18 @@ exports.download = function(urladdr, dest, args) {
args.push(urladdr);

// soft check for youtube video
var isYouToube = urladdr.match(/(youtube|youtu.be)/), details, query, id;
var isYouToube = urladdr.match(/(youtube|youtu.be)/),
details = url.parse(urladdr, true),
query = details.query,
id = query.v;

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 (!id) { id = pathname; }
}

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

Expand Down

0 comments on commit a5eeb09

Please sign in to comment.