Skip to content

Get the YouTube, Vimeo, Vine, TikTok, Dailymotion, Microsoft Stream or VideoPress video id from a url

License

Notifications You must be signed in to change notification settings

shelfio/get-video-id

Repository files navigation

@shelf/get-video-id CircleCI

Wrapper around https://github.com/radiovisual/get-video-id to return video service query params (youtube starts from as an example )

Install

yarn add @shelf/get-video-id

Usage

import getVideoId from '@shelf/get-video-id';

getVideoId('https://youtu.be/LqTuxFElqag');
/** => {
  id: 'LqTuxFElqag',
  service: 'youtube',
  embedURL: 'https://www.youtube.com/embed/LqTuxFElqag'
} **/

getVideoId('https://youtu.be/LqTuxFElqag?t=7939'); // With time param
/** => {
  id: 'LqTuxFElqag',
  service: 'youtube',
  embedURL: 'https://www.youtube.com/embed/LqTuxFElqag?start=7939'
} **/

getVideoId('https://vimeo.com/259411563#t=50s');
/** => {
  id: '259411563',
  service: 'vimeo',
  embedURL: 'https://player.vimeo.com/video/259411563'
} **/

API

Documentation is available here

Publish

$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tags

License

MIT © Shelf