Description
When using YoutubeTranscript.fetchTranscript(videoId), the method throws the following error on some videos:
Cannot read properties of undefined (reading 'playerCaptionsTracklistRenderer')
This happens consistently for certain videos, even on the latest version of the library.
Example video
https://www.youtube.com/watch?v=I7_WXKhyGms
Minimal reproduction code
const { YoutubeTranscript } = require("youtube-transcript");
(async () => {
try {
const transcript = await YoutubeTranscript.fetchTranscript("I7_WXKhyGms");
console.log(transcript);
} catch (err) {
console.error(err);
}
})();
Error output
Cannot read properties of undefined (reading 'playerCaptionsTracklistRenderer')
Expected behavior
Instead of throwing a low-level parsing error, the library should:
- Return an empty array, or
- Throw a clear error such as
No captions available for this video
when captions are unavailable or the YouTube response structure is different.
Context / hypothesis
It seems that playerCaptionsTracklistRenderer is missing from the YouTube player response in some cases, for example:
- videos without captions
- restricted or age-gated videos
- region-restricted videos
- or when YouTube changes its internal response structure
A defensive check before accessing playerCaptionsTracklistRenderer would prevent this crash.
::contentReference[oaicite:0]{index=0}
Description
When using
YoutubeTranscript.fetchTranscript(videoId), the method throws the following error on some videos:This happens consistently for certain videos, even on the latest version of the library.
Example video
https://www.youtube.com/watch?v=I7_WXKhyGms
Minimal reproduction code
Error output
Expected behavior
Instead of throwing a low-level parsing error, the library should:
No captions available for this videowhen captions are unavailable or the YouTube response structure is different.
Context / hypothesis
It seems that
playerCaptionsTracklistRendereris missing from the YouTube player response in some cases, for example:A defensive check before accessing
playerCaptionsTracklistRendererwould prevent this crash.