You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: update package description and enhance README for clarity and usability
- Revised package.json description to better reflect functionality for AI summaries and workflows.
- Expanded README to provide a clearer overview of features, usage, and benefits, including a focus on timestamped transcripts and video metadata.
- Improved formatting and structure for better readability and user engagement.
@@ -71,11 +99,11 @@ The library exports two functions and three types.
71
99
72
100
Returns the caption track as an array of timed segments.
73
101
74
-
| Param | Type | Default | Notes |
75
-
|---|---|---|---|
76
-
|`videoID`|`string`| (required) | The 11-character YouTube video ID, e.g. `7GeFt8suV8E`. Not the full URL. |
77
-
|`lang`|`string`|`'en'`| ISO language code (`'en'`, `'es'`, `'fr'`, `'ja'`, …). Manual captions are preferred over auto-generated, and an exact match is preferred over a partial match. |
78
-
|`fetch`|`typeof fetch`| global `fetch`| Custom fetch implementation. Useful for adding caching, custom retries, or routing through a proxy. See [Customizing the transport](#customizing-the-transport). |
|`videoID`|`string`| (required) | The 11-character YouTube video ID, e.g. `7GeFt8suV8E`. Not the full URL.|
105
+
|`lang`|`string`|`'en'`| ISO language code (`'en'`, `'es'`, `'fr'`, `'ja'`, …). Manual captions are preferred over auto-generated, and an exact match is preferred over a partial match.|
106
+
|`fetch`|`typeof fetch`| global `fetch`| Custom fetch implementation. Useful for adding caching, custom retries, or routing through a proxy. See [Customizing the transport](#customizing-the-transport). |
79
107
80
108
Resolves to `Subtitle[]`. Returns an empty array if the video plays but has no caption track in the requested language. **Throws** if the video is unavailable on any extraction path (see [Error handling](#error-handling)).
81
109
@@ -98,9 +126,9 @@ If subtitles fail to extract but the video metadata is available, `subtitles` wi
98
126
99
127
```ts
100
128
interfaceSubtitle {
101
-
start:string; // Segment start time, seconds
102
-
dur:string; // Segment duration, seconds
103
-
text:string; // Decoded text content
129
+
start:string; // Segment start time, seconds
130
+
dur:string; // Segment duration, seconds
131
+
text:string; // Decoded text content
104
132
}
105
133
106
134
interfaceVideoDetails {
@@ -119,7 +147,11 @@ interface Options {
119
147
All three are exported by name and can be imported directly:
@@ -132,7 +164,7 @@ The `lang` argument is a hint, not a strict filter. Track selection precedence:
132
164
4.**Any track whose `vssId` contains the requested code** (partial match)
133
165
5.**The first available track** as a final fallback
134
166
135
-
If you pass `lang: 'en'` and the video only has Spanish manual captions, you'll get those — the library prefers *some* output over none. If you pass a code that doesn't exist on the video, you'll typically get the video's primary language track. To check whether you got what you asked for, inspect the first segment's text or compare against `VideoDetails.title` / `description`.
167
+
If you pass `lang: 'en'` and the video only has Spanish manual captions, you'll get those — the library prefers _some_ output over none. If you pass a code that doesn't exist on the video, you'll typically get the video's primary language track. To check whether you got what you asked for, inspect the first segment's text or compare against `VideoDetails.title` / `description`.
136
168
137
169
## Error handling
138
170
@@ -208,7 +240,7 @@ import { getSubtitles, type Subtitle } from 'youtube-caption-extractor';
208
240
asyncfunction getSubtitlesWithRetry(
209
241
videoID:string,
210
242
lang='en',
211
-
maxAttempts=3
243
+
maxAttempts=3,
212
244
):Promise<Subtitle[]> {
213
245
let lastError:unknown;
214
246
for (let attempt =1; attempt<=maxAttempts; attempt++) {
Copy file name to clipboardExpand all lines: package.json
+22-3Lines changed: 22 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
{
2
2
"name": "youtube-caption-extractor",
3
3
"version": "1.10.2",
4
-
"description": "A simple and efficient package to scrape and parse captions (subtitles) from YouTube videos, supporting both user-submitted and auto-generated captions with language options.",
4
+
"description": "Extract clean, timestamped YouTube captions, subtitles, transcripts, and video metadata for AI summaries, RAG, search, and slide-ready workflows.",
0 commit comments