Skip to content

micnews/youtube-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SYNOPSIS

YouTube URL tools

Build Status

USAGE

var youtubeUrl = require('youtube-url');

FUNCTIONS

youtubeUrl.valid

Validate YouTube URL

youtubeUrl.valid('https://www.youtube.com/watch?v=YoB8t0B4jx4');   // true
youtubeUrl.valid('https://www.other-url.com/watch?v=YoB8t0B4jx4'); // false

// works with youtu.be URLs too
youtubeUrl.valid('http://youtu.be/vzM3nApSvMg'); // true

youtubeUrl.extractId

Extract the video ID from a YouTube URL

youtubeUrl.extractId('https://www.youtube.com/watch?v=YoB8t0B4jx4');
// returns YoB8t0B4jx4

youtubeUrl.extractId('https://www.other-url.com/watch?v=YoB8t0B4jx4');
// returns false

##LICENSE

MIT