JSPM

  • Created
  • Published
  • Downloads 79437
  • Score
    100M100P100Q156223F
  • License MIT

Get the youtube or vimeo video id from a url or embed string.

Package Exports

  • get-video-id

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (get-video-id) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

get-video-id

Get the youtube or vimeo video id from a url or embed string.

Build Status Coverage Status

Install

$ npm install --save get-video-id

Usage

const getVideoId = require('get-video-id');

getVideoId('https://www.youtube.com/watch?v=8rSH8-pbHZ0');
//=> '8rSH8-pbHZ0'

API

getVideoId(input)

input

Type: string

The youtube or vimeo url or embed code from which you want to find the video id. See the Patterns section to see the formats that can be supplied.

Patterns

This module will extract the video id from the following url / embed patterns:

Youtube

"""
// shortcodes
http://youtu.be/*?
https://youtu.be/*
http://youtu.be/*
youtube://

// /v/ or /vi/
http://www.youtube.com/v/*
http://youtube.com/vi/*?
http://youtube.com/v/*?

// v= or vi=
http://www.youtube.com/ytscreeningroom?v=*
http://www.youtube.com/watch?v=*?&
https://www.youtube.com/watch?v=*
http://youtube.com/watch?vi=*&
http://youtube.com/?vi=*&
http://youtube.com/?v=*

// embed
http://www.youtube.com/embed/*?
www.youtube-nocookie.com/embed/*?
https://www.youtube.com/embed/*

// user
http://www.youtube.com/user/username#p/a/u/2/*
http://www.youtube.com/user/username#p/u/1/*?
http://www.youtube.com/user/username#p/u/1/*

// iframe embed
<iframe width="560" height="315" src="https://www.youtube.com/embed/*" frameborder="0" allowfullscreen></iframe>
"""

Note: any youtube url that has -no-cookie in it is also supported.

Vimeo

"""
// urls
https://vimeo.com/*
https://player.vimeo.com/video/*

// iframe embed
<iframe src="https://player.vimeo.com/video/*" ...
"""

License

MIT © Michael Wuergler