devhims / youtube-caption-extractor

A lightweight package to scrape and parse captions (subtitles) from YouTube videos, supporting both user-submitted and auto-generated captions with language options.
https://youtube-caption-extractor.vercel.app
53 stars 8 forks source link

Fail to fetch caption of video if it requires user's consensus #1

Open m0o0scar opened 1 year ago

m0o0scar commented 1 year ago

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:

Snipaste_2023-08-15_10-59-18

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 [];
}