Skip to content

fetchTranscript fails when playerCaptionsTracklistRenderer is missing #49

@wilonweb

Description

@wilonweb

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions