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
- Host: GitHub
- URL: https://github.com/arjun-g/youtube-video-parser
- Owner: arjun-g
- Created: 2018-12-27T17:41:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-16T16:05:48.000Z (over 6 years ago)
- Last Synced: 2025-03-02T22:34:40.010Z (about 2 months ago)
- Language: TypeScript
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.