JSPM

  • Created
  • Published
  • Downloads 95700
  • Score
    100M100P100Q153399F
  • 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

This module will extract the Youtube or Vimeo Video ID from any known Youtube or Vimeo url pattern, including embed strings. If you discover a Youtube or Vimeo url pattern that is not covered by this module, please open an issue to report it, or submit a Pull Request. Thanks!

Install

$ npm install --save get-video-id

Usage

Simply supply the module with any known Youtube or Vimeo url (or embed string) and the ID will be extracted:

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 url / embed patterns below.
(where * = the id and ? or & = parameter strings):

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

Youtube -nocookie

www.youtube-nocookie.com/embed/*?

Vimeo urls

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

Vimeo iframe

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

License

MIT © Michael Wuergler