An open API service indexing awesome lists of open source software.

https://github.com/arjun-g/youtube-video-parser

Extract details related to a YouTube video
https://github.com/arjun-g/youtube-video-parser

Last synced: about 1 month ago
JSON representation

Extract details related to a YouTube video

Awesome Lists containing this project

README

        

# YouTube Video Parser
> Extract publicly available details related to a YouTube video

## Installation

`> npm install youtube-video-parser --save`

OR

`> yarn add youtube-video-parser`

## Usage

```js
//Import library
import { YouTubeVideo } from 'youtube-video-parser';

//Get YouTube video id from url
const videoId = YouTubeVideo.getVideoId('https://www.youtube.com/watch?v=ogfYd705cRs');

//Get video details from videoId
const video = await YouTubeVideo.fetch(videoId);

/* video object will be in the structure
{
videoId: string
title: string
duration: number
keywords: Array
channelId: string
thumbnails: Array<{
url: string
width: string
height: string
type: 'HighRes' | 'Default' | 'Other'
}>
author: string
viewCount: number
avgRating: number
isLive: boolean
caption: {
tracks: Array<{
url: string
language: {
code: string
name: string
}
autoGenerated: boolean
rtl: boolean
captions(): Promise>
}>
}
language: string
streamingData: {
expiresIn: number
formats: Array<{
itag: number
url: string
mimeType: {
type: string
codec: string
}
bitrate: number
avgBitrate: number
width: number
height: number
contentLength: number
quality: string
qualityLabel: string
audioQuality: 'Low' | 'Medium' | 'High'
audioSampleRate: number
duration: number
highReplication: boolean
}>
adaptiveFormats: Array<{
itag: number
url: string
mimeType: {
type: string
codec: string
}
bitrate: number
avgBitrate: number
width: number
height: number
contentLength: number
quality: string
qualityLabel: string
audioQuality: 'Low' | 'Medium' | 'High'
audioSampleRate: number
duration: number
highReplication: boolean
isVideoOnly: boolean
isAudioOnly: boolean
fps: number
}>
}
}
*/

//Get english language captions
const captionInfo = video.caption.tracks.find(track => track.language.code === 'en');
const captions = await captionInfo.captions();
```

## Disclaimer

This library is developed for research and educational purpose. Please check YouTube's terms and conditions before using it in production.