Youtube transcript api
npm install youtube-video-transcript
npm i youtube-video-transcript
`
$3
Import it in node js / deno like this
`js
import Transcriptor from 'youtube-video-transcript';
`
$3
If you want to use it in your browser
`html
Import Inspector
`
$3
You also need to setup a proxy (Hello Cors), but don't worry i provide you a small handler to do it
Create a new file server.js
Copy / Paste the following code
`js
import { Server } from 'youtube-video-transcript';
Server.default.listen(8080);
`
Then run node server.js
$3
All the following exemple will use the file mjs in local assuming that you have run the npm install command but if you don't want to it you can use the following
`html
`
But you will need to install a proxy like tiny-cors-proxy to bypass the cors option
You can install this package via npm:
`shell
npm install tiny-cors-proxy
`
Then create a new file server.js and paste the following snipset :
`js
import Server from 'tiny-cors-proxy';
Server.listen(8080);
`
Then run node server.js
Example
$3
#### Server Side
Quickly import and translate the video of your choice !
`js
import Transcriptor from 'youtube-video-transcript';
await Transcriptor.getTranscript('url or video id', ['en'])
`
#### Client Side
If you are working directly in your browser (you must setup a proxy server)
`html
Fetch Transcript of a video in specific language
`
#### Data
You will receive something like that
`json
{
"language" : "en",
"type" : "auto",
"data" : [
{
"start": 0,
"duration": 6.339,
"text": "Hello everyone thanks you so much for the last video"
}
]
}
`
$3
#### Server Side
It's also possible to fetch transcripts in multiple language
`js
import Transcriptor from 'youtube-video-transcript';
await Transcriptor.getTranscript('url or video id', ['en', 'es'])
`
#### Client Side
If you are working directly in your browser (you must setup a proxy server)
`html
Fetch Transcript of a video in specific language
`
#### Data
You will receive something like that
`json
[
{
"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!"
}
]
}
]
`
$3
#### Server Side
If you want you can download multiple transcripts from different videos
`js
import Transcriptor from 'youtube-video-transcript';
await Transcriptor.getTranscript(['url video 1', 'url video 2'], ['en'])
`
#### Client Side
If you are working directly in your browser (you must setup a proxy server)
`html
Fetch Transcript of a video in specific language
`
#### Data
You will receive something like that
`json
[
{
"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 !"
}
]
}
]
`
$3
Sometimes you just wan to fetch all the transcripts available
#### Server Side
If you want you can download multiple transcripts from different videos
`js
import Transcriptor from 'youtube-video-transcript';
const listTranscripts = await Transcriptor.listTranscripts('video url')
`
#### Client Side
If you are working directly in your browser (you must setup a proxy server)
`html
Fetch Transcript of a video in specific language
`
#### Other functions
To get all the transcripts as an array
`js
listTranscripts.list()
`
Filter to only have the transcriptions who are generated by AI form youtube
`js
listTranscripts.getAuto()
`
Filter to only have the transcriptions who are manually add by youtube creator
`js
listTranscripts.getManual()
`
Filter to only have the transcriptions in some specific languages
`js
listTranscripts.getMultipleLanguages(['en', 'fr', 'es'])
``