youtube-transcript-plus 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,10 @@ A Node.js library to fetch transcripts from YouTube videos. This package uses Yo
6
6
 
7
7
  **Note:** This project was originally forked from [https://github.com/Kakulukian/youtube-transcript](https://github.com/Kakulukian/youtube-transcript).
8
8
 
9
+ ## Requirements
10
+
11
+ - Node.js >= 20.0.0 (Node 20.x reaches EOL in September 2026)
12
+
9
13
  ## Installation
10
14
 
11
15
  ```bash
@@ -167,6 +171,90 @@ fetchTranscript('videoId_or_URL', {
167
171
  .catch(console.error);
168
172
  ```
169
173
 
174
+ ### List Available Languages
175
+
176
+ Discover what caption languages are available for a video without downloading transcript data.
177
+
178
+ ```javascript
179
+ import { listLanguages } from 'youtube-transcript-plus';
180
+
181
+ const languages = await listLanguages('videoId_or_URL');
182
+ // [
183
+ // { languageCode: 'en', languageName: 'English', isAutoGenerated: false },
184
+ // { languageCode: 'es', languageName: 'Spanish', isAutoGenerated: true },
185
+ // ]
186
+ ```
187
+
188
+ ### Transcript Format Output
189
+
190
+ Convert transcript segments to common subtitle formats or plain text.
191
+
192
+ ```javascript
193
+ import { fetchTranscript, toSRT, toVTT, toPlainText } from 'youtube-transcript-plus';
194
+
195
+ const transcript = await fetchTranscript('videoId_or_URL');
196
+
197
+ // SubRip format (.srt)
198
+ const srt = toSRT(transcript);
199
+
200
+ // WebVTT format (.vtt)
201
+ const vtt = toVTT(transcript);
202
+
203
+ // Plain text (one line per segment)
204
+ const text = toPlainText(transcript);
205
+
206
+ // Plain text with custom separator
207
+ const paragraph = toPlainText(transcript, ' ');
208
+ ```
209
+
210
+ ### Video Details
211
+
212
+ Opt in to receive video metadata alongside the transcript. This uses data already present in the API response, so it adds zero additional HTTP requests.
213
+
214
+ ```javascript
215
+ import { fetchTranscript } from 'youtube-transcript-plus';
216
+
217
+ const result = await fetchTranscript('videoId_or_URL', {
218
+ videoDetails: true,
219
+ });
220
+
221
+ console.log(result.videoDetails.title);
222
+ console.log(result.videoDetails.author);
223
+ console.log(result.videoDetails.lengthSeconds);
224
+ console.log(result.videoDetails.viewCount);
225
+ console.log(result.segments); // TranscriptSegment[]
226
+ ```
227
+
228
+ ### Retry with Exponential Backoff
229
+
230
+ Automatically retry on transient failures (429 rate-limit and 5xx server errors) with exponential backoff.
231
+
232
+ ```javascript
233
+ fetchTranscript('videoId_or_URL', {
234
+ retries: 3, // Retry up to 3 times
235
+ retryDelay: 1000, // Start with 1 second delay (doubles each retry)
236
+ })
237
+ .then(console.log)
238
+ .catch(console.error);
239
+ ```
240
+
241
+ ### AbortController Support
242
+
243
+ Cancel in-flight requests using an `AbortSignal`.
244
+
245
+ ```javascript
246
+ const controller = new AbortController();
247
+
248
+ // Cancel the request after 5 seconds
249
+ setTimeout(() => controller.abort(), 5000);
250
+
251
+ fetchTranscript('videoId_or_URL', {
252
+ signal: controller.signal,
253
+ })
254
+ .then(console.log)
255
+ .catch(console.error);
256
+ ```
257
+
170
258
  ### Error Handling
171
259
 
172
260
  The library throws specific errors for different failure scenarios. Each error includes a `videoId` property for programmatic handling.
@@ -177,6 +265,7 @@ import {
177
265
  YoutubeTranscriptDisabledError,
178
266
  YoutubeTranscriptNotAvailableError,
179
267
  YoutubeTranscriptNotAvailableLanguageError,
268
+ YoutubeTranscriptInvalidLangError,
180
269
  } from 'youtube-transcript-plus';
181
270
 
182
271
  fetchTranscript('videoId_or_URL')
@@ -190,6 +279,8 @@ fetchTranscript('videoId_or_URL')
190
279
  console.error('No transcript available:', error.videoId);
191
280
  } else if (error instanceof YoutubeTranscriptNotAvailableLanguageError) {
192
281
  console.error('Language not available:', error.lang, error.availableLangs);
282
+ } else if (error instanceof YoutubeTranscriptInvalidLangError) {
283
+ console.error('Invalid language code:', error.lang);
193
284
  } else {
194
285
  console.error('An unexpected error occurred:', error.message);
195
286
  }
@@ -206,6 +297,11 @@ The repository includes several example files in the `example/` directory to dem
206
297
  4. **`language-usage.js`**: Shows how to fetch a transcript in a specific language (e.g., French).
207
298
  5. **`proxy-usage.js`**: Demonstrates how to use a proxy server to fetch transcripts, which can be useful for bypassing rate limits or accessing restricted content.
208
299
  6. **`custom-fetch-usage.js`**: Shows how to use all three custom fetch functions (`videoFetch`, `playerFetch`, `transcriptFetch`) with logging and custom headers.
300
+ 7. **`list-languages-usage.js`**: Shows how to discover available caption languages for a video.
301
+ 8. **`format-output-usage.js`**: Demonstrates converting transcripts to SRT, VTT, and plain text formats.
302
+ 9. **`video-details-usage.js`**: Shows how to fetch video metadata alongside the transcript.
303
+ 10. **`retry-usage.js`**: Demonstrates retry with exponential backoff for transient failures.
304
+ 11. **`abort-usage.js`**: Shows how to cancel requests using an AbortController with a timeout.
209
305
 
210
306
  These examples can be found in the `example/` directory of the repository.
211
307
 
@@ -214,10 +310,21 @@ These examples can be found in the `example/` directory of the repository.
214
310
  All types are exported for TypeScript consumers:
215
311
 
216
312
  ```typescript
217
- import type { TranscriptConfig, TranscriptResponse, FetchParams, CacheStrategy } from 'youtube-transcript-plus';
313
+ import type {
314
+ TranscriptConfig,
315
+ TranscriptSegment,
316
+ TranscriptResult,
317
+ VideoDetails,
318
+ Thumbnail,
319
+ CaptionTrackInfo,
320
+ FetchParams,
321
+ CacheStrategy,
322
+ } from 'youtube-transcript-plus';
218
323
  ```
219
324
 
220
- ### API
325
+ > **Note:** `TranscriptResponse` is still available as a deprecated alias for `TranscriptSegment`.
326
+
327
+ ## API
221
328
 
222
329
  ### `fetchTranscript(videoId: string, config?: TranscriptConfig)`
223
330
 
@@ -225,21 +332,55 @@ Fetches the transcript for a YouTube video.
225
332
 
226
333
  - **`videoId`**: The YouTube video ID or URL.
227
334
  - **`config`**: Optional configuration object with the following properties:
228
- - **`lang`**: Language code (e.g., `'en'`, `'fr'`) for the transcript.
335
+ - **`lang`**: BCP 47 language code (e.g., `'en'`, `'fr'`, `'pt-BR'`) for the transcript.
229
336
  - **`userAgent`**: Custom User-Agent string.
230
- - **`cache`**: Custom caching strategy.
337
+ - **`cache`**: Custom caching strategy implementing `CacheStrategy`.
231
338
  - **`cacheTTL`**: Time-to-live for cache entries in milliseconds.
232
339
  - **`disableHttps`**: Set to `true` to use HTTP instead of HTTPS for YouTube requests.
233
340
  - **`videoFetch`**: Custom fetch function for the video page request (GET).
234
341
  - **`playerFetch`**: Custom fetch function for the YouTube Innertube API request (POST).
235
342
  - **`transcriptFetch`**: Custom fetch function for the transcript data request (GET).
343
+ - **`retries`**: Maximum number of retry attempts for transient failures (429, 5xx). Defaults to `0`.
344
+ - **`retryDelay`**: Base delay in milliseconds for exponential backoff. Defaults to `1000`.
345
+ - **`signal`**: `AbortSignal` to cancel in-flight requests.
346
+ - **`videoDetails`**: When `true`, returns a `TranscriptResult` with video metadata instead of a plain array.
236
347
 
237
- Returns a `Promise<TranscriptResponse[]>` where each item in the array represents a transcript segment with the following properties:
348
+ Returns a `Promise<TranscriptSegment[]>` where each item represents a transcript segment:
238
349
 
239
- - **`text`**: The text of the transcript segment.
350
+ - **`text`**: The text content of the segment.
240
351
  - **`duration`**: The duration of the segment in seconds.
241
352
  - **`offset`**: The start time of the segment in seconds.
242
- - **`lang`**: The language of the transcript.
353
+ - **`lang`**: The language code of the transcript.
354
+
355
+ When `videoDetails: true` is set, returns a `Promise<TranscriptResult>`:
356
+
357
+ - **`videoDetails`**: A `VideoDetails` object with `title`, `author`, `channelId`, `lengthSeconds`, `viewCount`, `description`, `keywords`, `thumbnails`, and `isLiveContent`.
358
+ - **`segments`**: An array of `TranscriptSegment` objects.
359
+
360
+ ### `listLanguages(videoId: string, config?: TranscriptConfig)`
361
+
362
+ Lists available caption languages for a video without downloading transcript data.
363
+
364
+ - **`videoId`**: The YouTube video ID or URL.
365
+ - **`config`**: Optional configuration (same options as `fetchTranscript`, except `videoDetails`).
366
+
367
+ Returns a `Promise<CaptionTrackInfo[]>`:
368
+
369
+ - **`languageCode`**: BCP 47 language code (e.g., `'en'`, `'fr'`).
370
+ - **`languageName`**: Human-readable language name (e.g., `'English'`).
371
+ - **`isAutoGenerated`**: Whether the captions are auto-generated by YouTube.
372
+
373
+ ### `toSRT(segments: TranscriptSegment[])`
374
+
375
+ Converts transcript segments to SubRip (SRT) format with sequence numbers and `HH:MM:SS,mmm` timestamps.
376
+
377
+ ### `toVTT(segments: TranscriptSegment[])`
378
+
379
+ Converts transcript segments to WebVTT format with `WEBVTT` header and `HH:MM:SS.mmm` timestamps.
380
+
381
+ ### `toPlainText(segments: TranscriptSegment[], separator?: string)`
382
+
383
+ Converts transcript segments to plain text, joined by the given separator (defaults to `'\n'`).
243
384
 
244
385
  ## Errors
245
386
 
@@ -251,6 +392,11 @@ The library throws the following errors:
251
392
  - **`YoutubeTranscriptNotAvailableLanguageError`**: The transcript is not available in the specified language. Properties: `videoId`, `lang`, `availableLangs`.
252
393
  - **`YoutubeTranscriptTooManyRequestError`**: YouTube is rate-limiting requests from your IP.
253
394
  - **`YoutubeTranscriptInvalidVideoIdError`**: The provided video ID or URL is invalid.
395
+ - **`YoutubeTranscriptInvalidLangError`**: The provided language code is not a valid BCP 47 code. Properties: `lang`.
396
+
397
+ ## Feature Requests
398
+
399
+ Have a feature idea? [Open an issue](https://github.com/ericmmartin/youtube-transcript-plus/issues/new) and let us know!
254
400
 
255
401
  ## License
256
402
 
@@ -1,8 +1,26 @@
1
1
  import { CacheStrategy } from '../types';
2
+ /**
3
+ * File-system-based cache implementation.
4
+ *
5
+ * Each entry is stored as a JSON file in the specified directory.
6
+ * Expired entries are automatically deleted when accessed.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { fetchTranscript, FsCache } from 'youtube-transcript-plus';
11
+ * const transcript = await fetchTranscript('dQw4w9WgXcQ', {
12
+ * cache: new FsCache('./my-cache-dir', 86400000), // 1 day TTL
13
+ * });
14
+ * ```
15
+ */
2
16
  export declare class FsCache implements CacheStrategy {
3
17
  private cacheDir;
4
18
  private defaultTTL;
5
19
  private ready;
20
+ /**
21
+ * @param cacheDir - Directory to store cache files. Created automatically if it doesn't exist.
22
+ * @param defaultTTL - Default time-to-live in milliseconds. Defaults to 1 hour.
23
+ */
6
24
  constructor(cacheDir?: string, defaultTTL?: number);
7
25
  get(key: string): Promise<string | null>;
8
26
  set(key: string, value: string, ttl?: number): Promise<void>;
@@ -1,7 +1,21 @@
1
1
  import { CacheStrategy } from '../types';
2
+ /**
3
+ * In-memory cache implementation using a `Map`.
4
+ *
5
+ * Entries are automatically cleaned up when accessed after expiration.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { fetchTranscript, InMemoryCache } from 'youtube-transcript-plus';
10
+ * const transcript = await fetchTranscript('dQw4w9WgXcQ', {
11
+ * cache: new InMemoryCache(1800000), // 30 minutes TTL
12
+ * });
13
+ * ```
14
+ */
2
15
  export declare class InMemoryCache implements CacheStrategy {
3
16
  private cache;
4
17
  private defaultTTL;
18
+ /** @param defaultTTL - Default time-to-live in milliseconds. Defaults to 1 hour. */
5
19
  constructor(defaultTTL?: number);
6
20
  get(key: string): Promise<string | null>;
7
21
  set(key: string, value: string, ttl?: number): Promise<void>;
package/dist/errors.d.ts CHANGED
@@ -1,24 +1,38 @@
1
+ /** Thrown when YouTube is rate-limiting requests from your IP address. */
1
2
  export declare class YoutubeTranscriptTooManyRequestError extends Error {
2
3
  constructor();
3
4
  }
5
+ /** Thrown when the requested video is unavailable or has been removed. */
4
6
  export declare class YoutubeTranscriptVideoUnavailableError extends Error {
5
7
  readonly videoId: string;
6
8
  constructor(videoId: string);
7
9
  }
10
+ /** Thrown when transcripts are disabled for the video by its owner. */
8
11
  export declare class YoutubeTranscriptDisabledError extends Error {
9
12
  readonly videoId: string;
10
13
  constructor(videoId: string);
11
14
  }
15
+ /** Thrown when no transcripts are available for the video. */
12
16
  export declare class YoutubeTranscriptNotAvailableError extends Error {
13
17
  readonly videoId: string;
14
18
  constructor(videoId: string);
15
19
  }
20
+ /** Thrown when the transcript is not available in the requested language. */
16
21
  export declare class YoutubeTranscriptNotAvailableLanguageError extends Error {
17
22
  readonly videoId: string;
23
+ /** The requested language code that was not available. */
18
24
  readonly lang: string;
25
+ /** The language codes that are available for this video. */
19
26
  readonly availableLangs: string[];
20
27
  constructor(lang: string, availableLangs: string[], videoId: string);
21
28
  }
29
+ /** Thrown when the provided `lang` option is not a valid BCP 47 language code. */
30
+ export declare class YoutubeTranscriptInvalidLangError extends Error {
31
+ /** The invalid language code that was provided. */
32
+ readonly lang: string;
33
+ constructor(lang: string);
34
+ }
35
+ /** Thrown when the provided video ID or URL is invalid. */
22
36
  export declare class YoutubeTranscriptInvalidVideoIdError extends Error {
23
37
  constructor();
24
38
  }
@@ -0,0 +1,57 @@
1
+ import { TranscriptSegment } from './types';
2
+ /**
3
+ * Convert transcript segments to SubRip (SRT) format.
4
+ *
5
+ * @param segments - Array of transcript segments from {@link fetchTranscript}.
6
+ * @returns A string in SRT format with sequence numbers and `HH:MM:SS,mmm` timestamps.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { fetchTranscript, toSRT } from 'youtube-transcript-plus';
11
+ * const transcript = await fetchTranscript('dQw4w9WgXcQ');
12
+ * const srt = toSRT(transcript);
13
+ *
14
+ * // With videoDetails enabled, use result.segments:
15
+ * const result = await fetchTranscript('dQw4w9WgXcQ', { videoDetails: true });
16
+ * const srt2 = toSRT(result.segments);
17
+ * ```
18
+ */
19
+ export declare function toSRT(segments: TranscriptSegment[]): string;
20
+ /**
21
+ * Convert transcript segments to WebVTT (VTT) format.
22
+ *
23
+ * @param segments - Array of transcript segments from {@link fetchTranscript}.
24
+ * @returns A string in VTT format with `WEBVTT` header and `HH:MM:SS.mmm` timestamps.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { fetchTranscript, toVTT } from 'youtube-transcript-plus';
29
+ * const transcript = await fetchTranscript('dQw4w9WgXcQ');
30
+ * const vtt = toVTT(transcript);
31
+ *
32
+ * // With videoDetails enabled, use result.segments:
33
+ * const result = await fetchTranscript('dQw4w9WgXcQ', { videoDetails: true });
34
+ * const vtt2 = toVTT(result.segments);
35
+ * ```
36
+ */
37
+ export declare function toVTT(segments: TranscriptSegment[]): string;
38
+ /**
39
+ * Convert transcript segments to plain text.
40
+ *
41
+ * @param segments - Array of transcript segments from {@link fetchTranscript}.
42
+ * @param separator - String to join segments with. Defaults to `'\n'`.
43
+ * @returns A plain text string with segments joined by the separator.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * import { fetchTranscript, toPlainText } from 'youtube-transcript-plus';
48
+ * const transcript = await fetchTranscript('dQw4w9WgXcQ');
49
+ * const text = toPlainText(transcript);
50
+ * const paragraph = toPlainText(transcript, ' ');
51
+ *
52
+ * // With videoDetails enabled, use result.segments:
53
+ * const result = await fetchTranscript('dQw4w9WgXcQ', { videoDetails: true });
54
+ * const text2 = toPlainText(result.segments);
55
+ * ```
56
+ */
57
+ export declare function toPlainText(segments: TranscriptSegment[], separator?: string): string;
package/dist/index.d.ts CHANGED
@@ -1,17 +1,148 @@
1
- import { TranscriptConfig, TranscriptResponse } from './types';
1
+ import { TranscriptConfig, TranscriptSegment, TranscriptResult, CaptionTrackInfo } from './types';
2
2
  /**
3
- * Implementation notes:
4
- * - Keeps the public surface identical.
5
- * - Internals now use YouTube Innertube `player` to discover captionTracks instead of scraping the watch HTML.
6
- * - Honors `lang`, custom fetch hooks (`videoFetch`, `transcriptFetch`), and optional cache strategy.
3
+ * Fetches YouTube video transcripts and caption metadata using the Innertube API.
4
+ *
5
+ * Can be used as an instance (with shared config) or via static/convenience methods.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Instance usage with shared config
10
+ * const yt = new YoutubeTranscript({ lang: 'en' });
11
+ * const transcript = await yt.fetchTranscript('dQw4w9WgXcQ');
12
+ * const languages = await yt.listLanguages('dQw4w9WgXcQ');
13
+ *
14
+ * // Static method
15
+ * const transcript = await YoutubeTranscript.fetchTranscript('dQw4w9WgXcQ', { lang: 'en' });
16
+ *
17
+ * // Opt-in to video details
18
+ * const { videoDetails, segments } = await YoutubeTranscript.fetchTranscript('dQw4w9WgXcQ', {
19
+ * videoDetails: true,
20
+ * });
21
+ *
22
+ * // Convenience export
23
+ * const transcript = await fetchTranscript('dQw4w9WgXcQ');
24
+ * const languages = await listLanguages('dQw4w9WgXcQ');
25
+ * ```
7
26
  */
8
27
  export declare class YoutubeTranscript {
9
28
  private config?;
10
- constructor(config?: TranscriptConfig);
11
- fetchTranscript(videoId: string): Promise<TranscriptResponse[]>;
12
- static fetchTranscript(videoId: string, config?: TranscriptConfig): Promise<TranscriptResponse[]>;
29
+ constructor(config?: TranscriptConfig | undefined);
30
+ /**
31
+ * Fetch caption tracks and the player response from the Innertube player API.
32
+ * Shared logic used by both fetchTranscript and listLanguages.
33
+ */
34
+ private _fetchCaptionTracks;
35
+ /**
36
+ * Extract VideoDetails from the Innertube player response.
37
+ */
38
+ private _extractVideoDetails;
39
+ /**
40
+ * Fetch the transcript for a YouTube video.
41
+ *
42
+ * When `videoDetails` is set to `true` in the config, returns a {@link TranscriptResult}
43
+ * containing both video metadata and transcript segments. Otherwise returns an array of
44
+ * {@link TranscriptSegment} objects.
45
+ *
46
+ * **Note:** The instance method returns a union type because `videoDetails` is set at
47
+ * construction time. For automatic type narrowing, use the static method or the
48
+ * `fetchTranscript` convenience export instead.
49
+ *
50
+ * @param videoId - A YouTube video ID (11 characters) or full YouTube URL.
51
+ * @returns An array of transcript segments, or a TranscriptResult if `videoDetails` is enabled.
52
+ * @throws {@link YoutubeTranscriptInvalidVideoIdError} if the video ID/URL is invalid.
53
+ * @throws {@link YoutubeTranscriptVideoUnavailableError} if the video is unavailable.
54
+ * @throws {@link YoutubeTranscriptDisabledError} if transcripts are disabled.
55
+ * @throws {@link YoutubeTranscriptNotAvailableError} if no transcript is available.
56
+ * @throws {@link YoutubeTranscriptNotAvailableLanguageError} if the requested language is unavailable.
57
+ * @throws {@link YoutubeTranscriptTooManyRequestError} if rate-limited by YouTube.
58
+ */
59
+ fetchTranscript(videoId: string): Promise<TranscriptSegment[] | TranscriptResult>;
60
+ /**
61
+ * List available caption languages for a YouTube video.
62
+ *
63
+ * Queries the Innertube player API to discover what caption tracks exist,
64
+ * without downloading any transcript data.
65
+ *
66
+ * @param videoId - A YouTube video ID (11 characters) or full YouTube URL.
67
+ * @returns An array of available caption track info objects.
68
+ * @throws {@link YoutubeTranscriptInvalidVideoIdError} if the video ID/URL is invalid.
69
+ * @throws {@link YoutubeTranscriptVideoUnavailableError} if the video is unavailable.
70
+ * @throws {@link YoutubeTranscriptDisabledError} if transcripts are disabled.
71
+ * @throws {@link YoutubeTranscriptNotAvailableError} if no captions are available.
72
+ * @throws {@link YoutubeTranscriptTooManyRequestError} if rate-limited by YouTube.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const yt = new YoutubeTranscript();
77
+ * const languages = await yt.listLanguages('dQw4w9WgXcQ');
78
+ * // [
79
+ * // { languageCode: 'en', languageName: 'English', isAutoGenerated: false },
80
+ * // { languageCode: 'es', languageName: 'Spanish (auto-generated)', isAutoGenerated: true },
81
+ * // ]
82
+ * ```
83
+ */
84
+ listLanguages(videoId: string): Promise<CaptionTrackInfo[]>;
85
+ /**
86
+ * Static convenience method to fetch a transcript without creating an instance.
87
+ *
88
+ * @param videoId - A YouTube video ID (11 characters) or full YouTube URL.
89
+ * @param config - Optional configuration options.
90
+ * @returns An array of transcript segments, or a {@link TranscriptResult} when `videoDetails: true`.
91
+ */
92
+ static fetchTranscript(videoId: string): Promise<TranscriptSegment[]>;
93
+ static fetchTranscript(videoId: string, config: TranscriptConfig & {
94
+ videoDetails: true;
95
+ }): Promise<TranscriptResult>;
96
+ static fetchTranscript(videoId: string, config: TranscriptConfig): Promise<TranscriptSegment[]>;
97
+ /**
98
+ * Static convenience method to list available caption languages without creating an instance.
99
+ *
100
+ * @param videoId - A YouTube video ID (11 characters) or full YouTube URL.
101
+ * @param config - Optional configuration options.
102
+ * @returns An array of available caption track info objects.
103
+ */
104
+ static listLanguages(videoId: string, config?: TranscriptConfig): Promise<CaptionTrackInfo[]>;
13
105
  }
14
- export type { CacheStrategy, TranscriptConfig, TranscriptResponse, FetchParams } from './types';
106
+ export type { CacheStrategy, CaptionTrackInfo, Thumbnail, TranscriptConfig, TranscriptResponse, TranscriptResult, TranscriptSegment, VideoDetails, FetchParams, } from './types';
15
107
  export { InMemoryCache, FsCache } from './cache';
108
+ export { toSRT, toVTT, toPlainText } from './formatters';
16
109
  export * from './errors';
17
- export declare const fetchTranscript: typeof YoutubeTranscript.fetchTranscript;
110
+ /**
111
+ * Convenience function to fetch a YouTube video transcript.
112
+ *
113
+ * @param videoId - A YouTube video ID (11 characters) or full YouTube URL.
114
+ * @param config - Optional configuration options.
115
+ * @returns An array of transcript segments, or a {@link TranscriptResult} when `videoDetails: true`.
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * import { fetchTranscript } from 'youtube-transcript-plus';
120
+ *
121
+ * // Returns TranscriptSegment[]
122
+ * const transcript = await fetchTranscript('dQw4w9WgXcQ');
123
+ *
124
+ * // Returns TranscriptResult with video details
125
+ * const { videoDetails, segments } = await fetchTranscript('dQw4w9WgXcQ', {
126
+ * videoDetails: true,
127
+ * });
128
+ * ```
129
+ */
130
+ export declare function fetchTranscript(videoId: string): Promise<TranscriptSegment[]>;
131
+ export declare function fetchTranscript(videoId: string, config: TranscriptConfig & {
132
+ videoDetails: true;
133
+ }): Promise<TranscriptResult>;
134
+ export declare function fetchTranscript(videoId: string, config: TranscriptConfig): Promise<TranscriptSegment[]>;
135
+ /**
136
+ * Convenience function to list available caption languages for a YouTube video.
137
+ *
138
+ * @param videoId - A YouTube video ID (11 characters) or full YouTube URL.
139
+ * @param config - Optional configuration options.
140
+ * @returns An array of available caption track info objects.
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * import { listLanguages } from 'youtube-transcript-plus';
145
+ * const languages = await listLanguages('dQw4w9WgXcQ');
146
+ * ```
147
+ */
148
+ export declare const listLanguages: typeof YoutubeTranscript.listLanguages;