A lightweight package to scrape and parse captions (subtitles) from YouTube videos, supporting both user-submitted and auto-generated captions with language options.
Hi. I found that for certain videos which require user's consensus before viewing, it'll fail to fetch the caption. For example this one:
https://www.youtube.com/watch?v=vi1Cun6mnVM
On YouTube, it will show this consensus screen before showing the video:
When examing the page source code, there is no captionTracks in it, which according to this part of index.ts will lead to the returning of an empty array:
// Check if the video page contains captions
if (!data.includes('captionTracks')) {
console.warn(`No captions found for video: ${videoID}`);
return [];
}
Hi. I found that for certain videos which require user's consensus before viewing, it'll fail to fetch the caption. For example this one: https://www.youtube.com/watch?v=vi1Cun6mnVM
On YouTube, it will show this consensus screen before showing the video:
When examing the page source code, there is no
captionTracks
in it, which according to this part ofindex.ts
will lead to the returning of an empty array: