JSPM

  • Created
  • Published
  • Downloads 95824
  • Score
    100M100P100Q153948F
  • 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://

Youtube /v/ or /vi/

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

Youtube 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=*

Youtube embed

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

Youtube 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/*

Youtube iframe

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

Vimeo urls

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

Vimeo iframe

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

Note: Any Youtube url that has -no-cookie in it is also supported.

License

MIT © Michael Wuergler