Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remarkablemark/youtube-video-id
📺 Extract the YouTube video ID from a string or URL.
https://github.com/remarkablemark/youtube-video-id
javascript npm youtube youtube-video-id
Last synced: 3 months ago
JSON representation
📺 Extract the YouTube video ID from a string or URL.
- Host: GitHub
- URL: https://github.com/remarkablemark/youtube-video-id
- Owner: remarkablemark
- License: mit
- Created: 2016-10-02T19:21:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T16:58:02.000Z (3 months ago)
- Last Synced: 2024-10-23T23:58:37.860Z (3 months ago)
- Topics: javascript, npm, youtube, youtube-video-id
- Language: JavaScript
- Homepage: https://npmjs.com/package/youtube-video-id
- Size: 2 MB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# youtube-video-id
[![NPM](https://nodei.co/npm/youtube-video-id.png)](https://nodei.co/npm/youtube-video-id/)
[![NPM version](https://img.shields.io/npm/v/youtube-video-id.svg)](https://www.npmjs.com/package/youtube-video-id)
[![build](https://github.com/remarkablemark/youtube-video-id/actions/workflows/build.yml/badge.svg)](https://github.com/remarkablemark/youtube-video-id/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/remarkablemark/youtube-video-id/graph/badge.svg?token=PQL6PG63WG)](https://codecov.io/gh/remarkablemark/youtube-video-id):tv: Extract the YouTube video ID from a string or URL:
```
YouTubeVideoId(string)
```[Replit](https://replit.com/@remarkablemark/youtube-video-id) | [JSFiddle](https://jsfiddle.net/remarkablemark/93fkfb22/) | [Examples](https://github.com/remarkablemark/youtube-video-id/tree/master/examples)
## Installation
[NPM](https://www.npmjs.com/package/youtube-video-id):
```sh
npm install youtube-video-id
```[Yarn](https://yarnpkg.com/package?name=youtube-video-id):
```sh
yarn add youtube-video-id
```[CDN](https://unpkg.com/browse/youtube-video-id/):
```html
```
## Usage
### Server
Import with ES Modules:
```js
import YouTubeVideoId from 'youtube-video-id';
```Or require with CommonJS:
```js
const YouTubeVideoId = require('youtube-video-id').default;
```Extract YouTube video ID from URL or string:
```js
YouTubeVideoId('https://www.youtube.com/watch?v=X3pTXG9a1oQ'); // 'X3pTXG9a1oQ'
YouTubeVideoId('https://youtu.be/X3pTXG9a1oQ'); // 'X3pTXG9a1oQ'
YouTubeVideoId('X3pTXG9a1oQ'); // 'X3pTXG9a1oQ'
```### Client
Load script:
```html
```
Extract YouTube video ID from URL or string:
```html
const videoId = YouTubeVideoId('https://www.youtube.com/watch?v=F2uovvU-dLA');
console.log(videoId);```
## Migration
### v1
Migrate to TypeScript and build ESM. CommonJS import now requires the `.default` key:
```js
const YouTubeVideoId = require('youtube-video-id').default;
```## Release
Release is automated with [Release Please](https://github.com/googleapis/release-please).
## License
[MIT](https://github.com/remarkablemark/youtube-video-id/blob/master/LICENSE)