Kakulukian / youtube-transcript

Fetch transcript from a youtube video
240 stars 51 forks source link

Please add example. #5

Closed nguyenlinhnttu closed 1 year ago

nguyenlinhnttu commented 1 year ago

Hello This is great library. So i am a newbie, i have a problem. static fetchTranscript(videoId: string, config?: TranscriptConfig) How to create config for this function, and how i can get list lang supported Can you add a example? Thanks

luke-z commented 1 year ago

The default config is

{
  lang: 'fr',
  country: 'FR'
}

So you can pass such an object with the new values you need.

You can try it with a video such as this https://www.youtube.com/watch?v=74ijsBhbxSQ which has multiple subtitles. For me it was enough to use the lang key.

To get all the available captions you can look for the captionTracks in the source of the video page. Using some sort of scraper you can get the values :)