Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikeesto/youtube-subtitle-transcript
This library fetches transcripts of YouTube videos. It leverages YouTube's built-in captions and parses them into a friendly JSON format.
https://github.com/mikeesto/youtube-subtitle-transcript
captions javascript subtitles transcripts typescript youtube
Last synced: about 2 months ago
JSON representation
This library fetches transcripts of YouTube videos. It leverages YouTube's built-in captions and parses them into a friendly JSON format.
- Host: GitHub
- URL: https://github.com/mikeesto/youtube-subtitle-transcript
- Owner: mikeesto
- License: mit
- Created: 2023-12-12T05:21:44.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-22T09:54:15.000Z (about 1 year ago)
- Last Synced: 2024-04-28T05:22:35.811Z (8 months ago)
- Topics: captions, javascript, subtitles, transcripts, typescript, youtube
- Language: TypeScript
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# YouTube Subtitle Transcript
This library fetches transcripts of YouTube videos. It leverages YouTube's built-in captions and parses them into a friendly JSON format.
## Installation
`npm install youtube-subtitle-transcript`
## Usage
```ts
import { fetchTranscript } from "youtube-subtitle-transcript";const { transcript, error } = await fetchTranscript("dQw4w9WgXcQ");
console.log(transcript);
```## API Reference
```ts
fetchTranscript(videoId: string, languageCode?: string): Promise
```- `videoId`: YouTube video ID (required).
- `languageCode`: Language code for the transcript (defaults to "en"). The library will always return manually created transcripts over automatically generated ones.
- Returns a Promise resolving to a `FetchTranscriptResult` object.`FetchTranscriptResult` interface
- `transcript`: An array of `TranscriptEntry` objects. If no transcript can be found, the array will be empty.
- `error`: An optional error message that will be present when a transcript cannot be found. Primarily to assist with debugging.`TranscriptEntry` interface
- `text`: The transcript text content.
- `start`: Starting time of the transcript segment in seconds (e.g. "1.23").
- `end`: Ending time of the transcript segment in seconds (e.g. "2.34").
- `duration`: Duration of the transcript segment in seconds (e.g. "1.11").## Credit
This library was highly inspired by [youtube-transcript-api](https://github.com/jdepoix/youtube-transcript-api). It is written in Python and has a lot more features than this one.
## License and disclaimer
MIT. This library uses undocumented parts of the YouTube API. It may break tomorrow.