1.0.3 • Published 6 months ago

youtube-video-id v1.0.3

Weekly downloads
274
License
MIT
Repository
github
Last release
6 months ago

youtube-video-id

NPM

NPM version build codecov

:tv: Extract the YouTube video ID from a string or URL:

YouTubeVideoId(string)

Replit | JSFiddle | Examples

Installation

NPM:

npm install youtube-video-id

Yarn:

yarn add youtube-video-id

CDN:

<script src="https://unpkg.com/youtube-video-id@latest/dist/youtube-video-id.min.js"></script>

Usage

Server

Import with ES Modules:

import YouTubeVideoId from 'youtube-video-id';

Or require with CommonJS:

const YouTubeVideoId = require('youtube-video-id').default;

Extract YouTube video ID from URL or string:

YouTubeVideoId('https://www.youtube.com/watch?v=X3pTXG9a1oQ'); // 'X3pTXG9a1oQ'
YouTubeVideoId('https://youtu.be/X3pTXG9a1oQ'); // 'X3pTXG9a1oQ'
YouTubeVideoId('X3pTXG9a1oQ'); // 'X3pTXG9a1oQ'

Client

Load script:

<script src="https://unpkg.com/youtube-video-id@latest/dist/youtube-video-id.min.js"></script>

Extract YouTube video ID from URL or string:

<script>
  const videoId = YouTubeVideoId('https://www.youtube.com/watch?v=F2uovvU-dLA');
  console.log(videoId);
</script>

Migration

v1

Migrate to TypeScript and build ESM. CommonJS import now requires the .default key:

const YouTubeVideoId = require('youtube-video-id').default;

Release

Release is automated with Release Please.

License

MIT

1.0.2

6 months ago

1.0.3

6 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.0.4

8 months ago

0.0.3

6 years ago

0.0.2

7 years ago

0.0.1

8 years ago