Youtube-Video-Api
![image](https://shields.io/badge/TypeScript-3178C6?logo=TypeScript&logoColor=FFF&style=flat-square)
A TypeScript Version of Youtube Transcript Api
Description
This repository provides a simple and efficient way to interact with the YouTube Transcript API. It is designed to fetch transcripts from YouTube videos, with support for both single and multiple video transcripts.
Installation
Run this command to install it
npm i youtube-transcript-api
Example
Quickly import and translate the video of your choice !
import Transcriptor from 'youtube-transcript-api';
await Transcriptor.getTranscript('url or video id', ['en'])
You will receive something like that
{
"language" : "en",
"type" : "auto",
"data" : [
{
"start": 0,
"duration": 6.339,
"text": "Hello everyone thanks you so much for the last video"
}
]
}
It's also possible to fetch transcripts in multiple language
import Transcriptor from 'youtube-transcript-api';
await Transcriptor.getTranscript('url or video id', ['en', 'es'])
You will receive something like that
{
"language" : "en",
"type" : "auto",
"data" : [
{
"start": 0,
"duration": 6.339,
"text": "Hello everyone thanks you so much for the last video"
}
]
},
{
"language" : "es",
"type" : "manual",
"data" : [
{
"start": 0,
"duration": 5.439,
"text": "¡Hola a todos, muchas gracias por el último video!"
}
]
}
If you want you can download multiple transcripts from different videos
import Transcriptor from 'youtube-transcript-api';
await Transcriptor.getTranscript(['url video 1', 'url video 2'], ['en'])
You will receive something like that
[
{
"language" : "en",
"type" : "auto",
"data" : [
{
"start": 0,
"duration": 6.339,
"text": "Hello everyone thanks you so much for the last video"
}
]
},
{
"language" : "en",
"type" : "auto",
"data" : [
{
"start": 0,
"duration": 1.219,
"text": "Welcome everybody !"
}
]
}
]
If you want you can fetch all the transcripts for a video by doing this
import Transcriptor from 'youtube-transcript-api';
const listTranscripts = await Transcriptor.listTranscripts('video url')
Then use this function to get all the transcripts as an array
listTranscripts.list()
Also you can filter this list to have only the transcripts who are generated
listTranscripts.getAuto()
Or who are created manually
listTranscripts.getManual()
In different languages
listTranscripts.getMultipleLanguages(['en', 'fr', 'es'])