Downloading YouTube Channels Transcript...

Is it possible for me to grab (download) a full list of transcripts from a youtube channel's videos. I am working on a small project, of which I need a list of the videos, like all of them to control+f and find specific words.

I was wondering if anyone knew of such program I could use.

However, I wrote this AppScript in Google Drive, of which I'm not sure if this will work. It uses high level Google Account Access.

function getYouTubeTranscripts() {
  const CHANNEL_ID = "UCtMVHI3AJD4Qk4hcbZnI9ZQ";

      // This below is what, before Oath (ing), is what Google is saying its unsafe, and does not let me continue...
  const youtube = YouTubeApp.getOAuth2Service().getService();
  const videoIds = youtube.search().list("id", { channelId: CHANNEL_ID, maxResults: 50 }).items.map(item => item.id.videoId);

  videoIds.forEach(videoId => {
    const captions = youtube.captions().list("snippet", { videoId }).items;
    if (captions.length > 0) {
      const captionId = captions[0].id;
      const transcript = youtube.captions().download(captionId, { tfmt: "srt" }).getContentText();
      DriveApp.createFile(`${videoId}.txt`, transcript, "text/plain");
      Logger.log(`Transcript for video ${videoId} saved.`);
    } else {
      Logger.log(`No transcript found for video ${videoId}.`);
    }
  });
}

Just wondering of anything else I could use...

SubArcticTundra ,
@SubArcticTundra@lemmy.ml avatar

Hmm, I'd have a look at the yt-dlp source code. I think it can download subtitles/transcripts (and list them). The process does take a few seconds though.

z3rOR0ne , (edited )
@z3rOR0ne@lemmy.ml avatar

I was just going to chime in with this. I don't know the details of their implementation, but I get transcripts with every video I download using yt-dlp (if it exists which it does 99.9% of the time).

Synther OP ,

am I able to download all the transcripts of each video from one channel? I was planning on doing this with a few channels. If this is even possible with YT-DL.

SubArcticTundra ,
@SubArcticTundra@lemmy.ml avatar

Hmm, youd need to first get a list of channel videos and then iterate thrpugh them, probablu with a script. Yt-dlp might support getting the videos in a channel, idk. I do know that it can download while playlists... Perhaps try passing it the channel url and seeing if it treats that as a playlost.

BehindTheBarrier ,

YouTube sometimes made it hard to find, but all channels do have an all videos Playlist. I think he button is on a profiles video page now. I don't know if yt-dlp can do only transcripts but I'm sure it can download all videos with transcripts included.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • webdev@programming.dev
  • test
  • worldmews
  • mews
  • All magazines