/youtube-transcript

Fetch transcript from a youtube video

Primary LanguageTypeScript

youtube-transcript

npm version

I wanted to extract a transcript from a youtube video but there was only a python script so I created this to do it in node. This package use unofficial YTB API so it can be broken over the time if no update appears.

Supports these Youtube URLs:

  • https://www.youtube.com/watch?v={ID}
  • https://www.youtube.com/embed/{ID}
  • https://www.youtube.com/e/{ID}
  • https://youtu.be/{ID}

Dependencies

Requires node-html-parser to parse transcription endpoint XML (does not respond with JSON).

Installation

$ npm i youtube-transcript node-html-parser

or

$ yarn add youtube-transcript node-html-parser

Usage

import { fetchTranscript } from 'youtube-transcript';

fetchTranscript('videoId or URL').then(console.log);

Methods

  • fetchTranscript(videoId: string [,options: TranscriptConfig]): Promise<TranscriptResponse[]>;

License

MIT Licensed