tubezero 1.0.0 → 1.1.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/LICENSE +661 -121
- package/README.md +32 -26
- package/dist/index.cjs +1802 -675
- package/dist/index.d.cts +412 -132
- package/dist/index.d.ts +412 -132
- package/dist/index.js +1778 -673
- package/package.json +74 -54
package/dist/index.d.cts
CHANGED
|
@@ -1,89 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* scraper.ts
|
|
3
|
-
* Scrapes user-specific YouTube feeds: History, Likes, Watch Later, and Custom Playlists.
|
|
4
|
-
* Works client-side (Chrome extensions, desktop apps, or CORS-proxied environments).
|
|
5
|
-
*/
|
|
6
|
-
interface VideoEntry {
|
|
7
|
-
title: string;
|
|
8
|
-
channel: string;
|
|
9
|
-
}
|
|
10
|
-
interface InnerTubeConfig {
|
|
11
|
-
apiKey: string | null;
|
|
12
|
-
clientVersion: string;
|
|
13
|
-
idToken: string | null;
|
|
14
|
-
}
|
|
15
|
-
interface CustomPlaylist {
|
|
16
|
-
url: string;
|
|
17
|
-
}
|
|
18
|
-
interface CustomPlaylistData {
|
|
19
|
-
id: string;
|
|
20
|
-
entries: VideoEntry[];
|
|
21
|
-
}
|
|
22
|
-
interface TasteData {
|
|
23
|
-
historyEntries: VideoEntry[];
|
|
24
|
-
likesEntries: VideoEntry[];
|
|
25
|
-
wlEntries: VideoEntry[];
|
|
26
|
-
dislikesEntries: VideoEntry[];
|
|
27
|
-
customPlaylistsData: CustomPlaylistData[];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Fetches the HTML of a YouTube page and extracts `ytInitialData`.
|
|
31
|
-
* @param url - The URL to fetch.
|
|
32
|
-
* @returns The parsed ytInitialData object or null.
|
|
33
|
-
*/
|
|
34
|
-
declare function fetchYtInitialData(url: string): Promise<any>;
|
|
35
|
-
/**
|
|
36
|
-
* Reads SAPISID cookies from the browser environment.
|
|
37
|
-
* Only works if running on a youtube.com domain or in an extension with cookie access.
|
|
38
|
-
* @returns The SAPISID value or null.
|
|
39
|
-
*/
|
|
40
|
-
declare function getSapisidFromCookie(): string | null;
|
|
41
|
-
/**
|
|
42
|
-
* Generates the SAPISIDHASH Authorization header value needed for authenticated InnerTube requests.
|
|
43
|
-
* @param sapisid - The SAPISID cookie value.
|
|
44
|
-
* @param origin - The request origin.
|
|
45
|
-
* @returns The generated authorization hash or null.
|
|
46
|
-
*/
|
|
47
|
-
declare function getSApiSidHash(sapisid: string, origin?: string): Promise<string | null>;
|
|
48
|
-
/**
|
|
49
|
-
* Recursively scans a JSON object to extract video entries { title, channel }.
|
|
50
|
-
* Handles both the legacy videoRenderer and the newer lockupViewModel schemas.
|
|
51
|
-
* @param data - The JSON object to search.
|
|
52
|
-
* @returns Array of extracted video entries.
|
|
53
|
-
*/
|
|
54
|
-
declare function extractVideoEntries(data: any): VideoEntry[];
|
|
55
|
-
/**
|
|
56
|
-
* Extracts InnerTube credentials and configuration parameters by parsing the YouTube home page.
|
|
57
|
-
* @param injectedConfig - Pre-fetched config if available (bypasses fetching).
|
|
58
|
-
* @returns InnerTube config parameters.
|
|
59
|
-
*/
|
|
60
|
-
declare function getInnerTubeConfig(injectedConfig?: Partial<InnerTubeConfig> | null): Promise<InnerTubeConfig>;
|
|
61
|
-
/**
|
|
62
|
-
* Recursively searches for the continuation token in an InnerTube response.
|
|
63
|
-
* @param obj - InnerTube response subtree.
|
|
64
|
-
* @returns The token or null.
|
|
65
|
-
*/
|
|
66
|
-
declare function findContinuationToken(obj: any): string | null;
|
|
67
|
-
/**
|
|
68
|
-
* Fetches video list from a specific InnerTube browse ID, paginating if needed.
|
|
69
|
-
* @param apiKey - InnerTube API Key.
|
|
70
|
-
* @param clientVersion - InnerTube client version string.
|
|
71
|
-
* @param idToken - Identity Token.
|
|
72
|
-
* @param browseId - Target feed ID (e.g. 'FEhistory', 'VLLL', 'VLWL').
|
|
73
|
-
* @param limit - Maximum entries to fetch.
|
|
74
|
-
* @returns Array of videos.
|
|
75
|
-
*/
|
|
76
|
-
declare function fetchInnerTubeFeed(apiKey: string, clientVersion: string, idToken: string | null, browseId: string, limit?: number): Promise<VideoEntry[]>;
|
|
77
|
-
/**
|
|
78
|
-
* Scrapes History, Liked videos, Watch Later, and any custom playlists.
|
|
79
|
-
* Tries the InnerTube JSON API first, then falls back to HTML-scraping + paginating if needed.
|
|
80
|
-
* @param injectedConfig - Preconfigured InnerTube parameters.
|
|
81
|
-
* @param customPlaylists - Custom playlist definitions with URLs/IDs.
|
|
82
|
-
* @param limit - Maximum items to retrieve per feed.
|
|
83
|
-
* @returns Scraped feeds.
|
|
84
|
-
*/
|
|
85
|
-
declare function scrapeTasteData(injectedConfig?: Partial<InnerTubeConfig> | null, customPlaylists?: CustomPlaylist[], limit?: number): Promise<TasteData>;
|
|
86
|
-
|
|
87
1
|
declare class Base {
|
|
88
2
|
client: Client;
|
|
89
3
|
constructor(client: Client);
|
|
@@ -105,10 +19,11 @@ interface Thumbnail {
|
|
|
105
19
|
width: number;
|
|
106
20
|
height: number;
|
|
107
21
|
}
|
|
108
|
-
declare class Thumbnails {
|
|
109
|
-
list
|
|
110
|
-
|
|
111
|
-
|
|
22
|
+
declare class Thumbnails extends Array<Thumbnail> {
|
|
23
|
+
constructor(list?: Thumbnail[] | number);
|
|
24
|
+
get min(): string | undefined;
|
|
25
|
+
get best(): string | undefined;
|
|
26
|
+
load(thumbnails: Thumbnail[]): Thumbnails;
|
|
112
27
|
}
|
|
113
28
|
|
|
114
29
|
interface ChannelInfo {
|
|
@@ -157,21 +72,208 @@ declare class SearchResult extends Continuable<SearchItem> {
|
|
|
157
72
|
private static parseData;
|
|
158
73
|
}
|
|
159
74
|
|
|
75
|
+
declare class ChannelVideos extends Continuable<VideoCompact> {
|
|
76
|
+
channel: BaseChannel;
|
|
77
|
+
constructor(client: Client, channel: BaseChannel);
|
|
78
|
+
protected fetch(): Promise<{
|
|
79
|
+
items: VideoCompact[];
|
|
80
|
+
continuation?: string | null;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
declare class ChannelShorts extends Continuable<VideoCompact> {
|
|
84
|
+
channel: BaseChannel;
|
|
85
|
+
constructor(client: Client, channel: BaseChannel);
|
|
86
|
+
protected fetch(): Promise<{
|
|
87
|
+
items: VideoCompact[];
|
|
88
|
+
continuation?: string | null;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
declare class ChannelLive extends Continuable<VideoCompact> {
|
|
92
|
+
channel: BaseChannel;
|
|
93
|
+
constructor(client: Client, channel: BaseChannel);
|
|
94
|
+
protected fetch(): Promise<{
|
|
95
|
+
items: VideoCompact[];
|
|
96
|
+
continuation?: string | null;
|
|
97
|
+
}>;
|
|
98
|
+
}
|
|
99
|
+
declare class ChannelPlaylists extends Continuable<PlaylistCompact> {
|
|
100
|
+
channel: BaseChannel;
|
|
101
|
+
constructor(client: Client, channel: BaseChannel);
|
|
102
|
+
protected fetch(): Promise<{
|
|
103
|
+
items: PlaylistCompact[];
|
|
104
|
+
continuation?: string | null;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
declare class ChannelPosts extends Continuable<any> {
|
|
108
|
+
channel: BaseChannel;
|
|
109
|
+
constructor(client: Client, channel: BaseChannel);
|
|
110
|
+
protected fetch(): Promise<{
|
|
111
|
+
items: any[];
|
|
112
|
+
continuation?: string | null;
|
|
113
|
+
}>;
|
|
114
|
+
}
|
|
115
|
+
declare class BaseChannel extends Base {
|
|
116
|
+
id: string;
|
|
117
|
+
name: string;
|
|
118
|
+
handle?: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
thumbnails?: Thumbnails;
|
|
121
|
+
subscriberCount?: string;
|
|
122
|
+
videos: ChannelVideos;
|
|
123
|
+
shorts: ChannelShorts;
|
|
124
|
+
live: ChannelLive;
|
|
125
|
+
playlists: ChannelPlaylists;
|
|
126
|
+
posts: ChannelPosts;
|
|
127
|
+
constructor(client: Client, data?: any);
|
|
128
|
+
get url(): string;
|
|
129
|
+
load(data: any): BaseChannel;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
declare class VideoRelated extends Continuable<VideoCompact | PlaylistCompact> {
|
|
133
|
+
video: Video;
|
|
134
|
+
constructor(client: Client, video: Video);
|
|
135
|
+
protected fetch(): Promise<{
|
|
136
|
+
items: (VideoCompact | PlaylistCompact)[];
|
|
137
|
+
continuation?: string | null;
|
|
138
|
+
}>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface CaptionSegment {
|
|
142
|
+
utf8: string;
|
|
143
|
+
tOffsetMs?: number;
|
|
144
|
+
acpText?: string;
|
|
145
|
+
}
|
|
146
|
+
declare class CaptionLanguage {
|
|
147
|
+
captions: VideoCaptions;
|
|
148
|
+
name: string;
|
|
149
|
+
code: string;
|
|
150
|
+
isTranslatable: boolean;
|
|
151
|
+
url: string;
|
|
152
|
+
constructor(attr: {
|
|
153
|
+
captions: VideoCaptions;
|
|
154
|
+
name: string;
|
|
155
|
+
code: string;
|
|
156
|
+
isTranslatable: boolean;
|
|
157
|
+
url: string;
|
|
158
|
+
});
|
|
159
|
+
get(translationLanguageCode?: string): Promise<Caption[] | undefined>;
|
|
160
|
+
}
|
|
161
|
+
declare class Caption {
|
|
162
|
+
duration: number;
|
|
163
|
+
start: number;
|
|
164
|
+
text: string;
|
|
165
|
+
segments?: CaptionSegment[];
|
|
166
|
+
constructor(attr: Partial<Caption>);
|
|
167
|
+
get end(): number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class VideoCaptions extends Base {
|
|
171
|
+
video: Video;
|
|
172
|
+
languages: CaptionLanguage[];
|
|
173
|
+
constructor(attr: {
|
|
174
|
+
video: Video;
|
|
175
|
+
client: Client;
|
|
176
|
+
});
|
|
177
|
+
load(data: any): VideoCaptions;
|
|
178
|
+
get(languageCode?: string, translationLanguageCode?: string): Promise<Caption[] | undefined>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface Format {
|
|
182
|
+
itag: number;
|
|
183
|
+
url: string;
|
|
184
|
+
mimeType: string;
|
|
185
|
+
bitrate: number;
|
|
186
|
+
width?: number;
|
|
187
|
+
height?: number;
|
|
188
|
+
hasVideo: boolean;
|
|
189
|
+
hasAudio: boolean;
|
|
190
|
+
isLive: boolean;
|
|
191
|
+
contentLength?: string;
|
|
192
|
+
quality?: string;
|
|
193
|
+
qualityLabel?: string;
|
|
194
|
+
audioQuality?: string;
|
|
195
|
+
approxDurationMs?: string;
|
|
196
|
+
}
|
|
197
|
+
interface StreamingData {
|
|
198
|
+
expiresInSeconds: string;
|
|
199
|
+
formats: Format[];
|
|
200
|
+
adaptiveFormats: Format[];
|
|
201
|
+
}
|
|
160
202
|
declare class BaseVideo extends Base {
|
|
161
203
|
id: string;
|
|
162
204
|
title: string;
|
|
163
205
|
description: string;
|
|
164
206
|
thumbnails: Thumbnails;
|
|
165
207
|
viewCount: number | null;
|
|
166
|
-
|
|
167
|
-
channel
|
|
168
|
-
|
|
169
|
-
|
|
208
|
+
uploadDate: string | null;
|
|
209
|
+
channel: BaseChannel | null;
|
|
210
|
+
channels: BaseChannel[] | null;
|
|
211
|
+
isLiveContent: boolean;
|
|
212
|
+
likeCount: number | null;
|
|
213
|
+
tags: string[];
|
|
214
|
+
formats: any[];
|
|
215
|
+
adaptiveFormats: any[];
|
|
216
|
+
streamingData?: StreamingData;
|
|
217
|
+
related: VideoRelated;
|
|
218
|
+
captions: VideoCaptions | null;
|
|
219
|
+
constructor(client: Client, data?: any);
|
|
170
220
|
protected parse(data: any): void;
|
|
221
|
+
get upNext(): any;
|
|
171
222
|
}
|
|
172
223
|
|
|
224
|
+
declare class CommentReplies extends Continuable<Comment> {
|
|
225
|
+
comment: Comment;
|
|
226
|
+
constructor(client: Client, comment: Comment);
|
|
227
|
+
protected fetch(): Promise<{
|
|
228
|
+
items: Comment[];
|
|
229
|
+
continuation?: string | null;
|
|
230
|
+
}>;
|
|
231
|
+
}
|
|
232
|
+
declare class VideoComments extends Continuable<Comment> {
|
|
233
|
+
video: Video;
|
|
234
|
+
constructor(client: Client, video: Video);
|
|
235
|
+
protected fetch(): Promise<{
|
|
236
|
+
items: Comment[];
|
|
237
|
+
continuation?: string | null;
|
|
238
|
+
}>;
|
|
239
|
+
}
|
|
240
|
+
declare class Comment extends Base {
|
|
241
|
+
id: string;
|
|
242
|
+
video: Video;
|
|
243
|
+
author: BaseChannel;
|
|
244
|
+
content: string;
|
|
245
|
+
publishDate: string;
|
|
246
|
+
likeCount: number;
|
|
247
|
+
isAuthorChannelOwner: boolean;
|
|
248
|
+
isPinned: boolean;
|
|
249
|
+
replyCount: number;
|
|
250
|
+
replies: CommentReplies;
|
|
251
|
+
constructor(client: Client, options: {
|
|
252
|
+
payload: any;
|
|
253
|
+
video: Video;
|
|
254
|
+
});
|
|
255
|
+
load(payload: any): Comment;
|
|
256
|
+
get url(): string;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface Chapter {
|
|
260
|
+
title: string;
|
|
261
|
+
start: number;
|
|
262
|
+
thumbnails: Thumbnails;
|
|
263
|
+
}
|
|
264
|
+
interface MusicMetadata {
|
|
265
|
+
imageUrl: string;
|
|
266
|
+
title: string;
|
|
267
|
+
artist: string;
|
|
268
|
+
album?: string | null;
|
|
269
|
+
}
|
|
173
270
|
declare class Video extends BaseVideo {
|
|
271
|
+
duration: number;
|
|
272
|
+
chapters: Chapter[];
|
|
273
|
+
comments: VideoComments;
|
|
274
|
+
music: MusicMetadata | null;
|
|
174
275
|
constructor(client: Client, data: any);
|
|
276
|
+
load(data: any): Video;
|
|
175
277
|
}
|
|
176
278
|
|
|
177
279
|
declare class PlaylistVideos extends Continuable<VideoCompact> {
|
|
@@ -194,87 +296,182 @@ declare class Playlist extends Base {
|
|
|
194
296
|
private parse;
|
|
195
297
|
}
|
|
196
298
|
|
|
299
|
+
interface ChannelShelf {
|
|
300
|
+
title: string;
|
|
301
|
+
subtitle?: string;
|
|
302
|
+
items: any[];
|
|
303
|
+
}
|
|
304
|
+
declare class Channel extends BaseChannel {
|
|
305
|
+
videoCount?: string;
|
|
306
|
+
banner: Thumbnails;
|
|
307
|
+
mobileBanner: Thumbnails;
|
|
308
|
+
tvBanner: Thumbnails;
|
|
309
|
+
shelves: ChannelShelf[];
|
|
310
|
+
constructor(client: Client, data?: any);
|
|
311
|
+
load(data: any): Channel;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare class MixPlaylist extends Base {
|
|
315
|
+
id: string;
|
|
316
|
+
title: string;
|
|
317
|
+
videoCount: number;
|
|
318
|
+
videos: VideoCompact[];
|
|
319
|
+
constructor(client: Client, data?: any);
|
|
320
|
+
load(data: any): MixPlaylist;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class LiveVideo extends BaseVideo {
|
|
324
|
+
watchingCount: number;
|
|
325
|
+
chatContinuation: string;
|
|
326
|
+
private delay;
|
|
327
|
+
private chatRequestPoolingTimeout;
|
|
328
|
+
private timeoutMs;
|
|
329
|
+
private isChatPlaying;
|
|
330
|
+
private chatQueue;
|
|
331
|
+
private pollSessionId;
|
|
332
|
+
private listeners;
|
|
333
|
+
constructor(client: Client, data?: any);
|
|
334
|
+
on(event: string, listener: Function): this;
|
|
335
|
+
emit(event: string, ...args: any[]): boolean;
|
|
336
|
+
load(data: any): LiveVideo;
|
|
337
|
+
playChat(delay?: number): void;
|
|
338
|
+
stopChat(): void;
|
|
339
|
+
private pollChatContinuation;
|
|
340
|
+
}
|
|
341
|
+
|
|
197
342
|
/**
|
|
198
343
|
* client.ts
|
|
199
344
|
* Core InnerTube Client class for TubeVanilla.
|
|
200
345
|
* Optimized for client-side environments with zero external dependencies.
|
|
201
346
|
*/
|
|
202
347
|
|
|
348
|
+
interface InnerTubeConfig {
|
|
349
|
+
apiKey: string | null;
|
|
350
|
+
clientVersion: string;
|
|
351
|
+
idToken: string | null;
|
|
352
|
+
}
|
|
353
|
+
interface Cache {
|
|
354
|
+
get(key: string): Promise<any> | any;
|
|
355
|
+
set(key: string, value: any): Promise<void> | void;
|
|
356
|
+
}
|
|
203
357
|
interface ClientOptions {
|
|
204
358
|
apiKey?: string | null;
|
|
205
359
|
clientVersion?: string;
|
|
206
360
|
idToken?: string | null;
|
|
207
361
|
cookie?: string;
|
|
362
|
+
fetch?: typeof globalThis.fetch;
|
|
363
|
+
cache?: Cache;
|
|
208
364
|
}
|
|
365
|
+
interface ClientProfile {
|
|
366
|
+
name: string;
|
|
367
|
+
clientName: string;
|
|
368
|
+
clientVersion: string;
|
|
369
|
+
clientNameHeader: string;
|
|
370
|
+
userAgent: string;
|
|
371
|
+
context: Record<string, any>;
|
|
372
|
+
}
|
|
373
|
+
declare function getSapisidFromCookieString(cookieString?: string): string | null;
|
|
374
|
+
declare function getSApiSidHash(sapisid: string, origin?: string): Promise<string | null>;
|
|
375
|
+
declare function getInnerTubeConfig(injectedConfig?: Partial<InnerTubeConfig> | null, customFetch?: typeof globalThis.fetch): Promise<InnerTubeConfig>;
|
|
209
376
|
declare class Client {
|
|
210
377
|
apiKey: string | null;
|
|
211
378
|
clientVersion: string;
|
|
212
379
|
idToken: string | null;
|
|
213
380
|
cookie: string;
|
|
381
|
+
fetch: typeof globalThis.fetch;
|
|
382
|
+
cache?: Cache;
|
|
214
383
|
constructor(options?: ClientOptions);
|
|
215
|
-
/**
|
|
216
|
-
* Asynchronously resolves config parameters if apiKey is not set yet.
|
|
217
|
-
* Fetches and parses YouTube's home page HTML using the scraper logic.
|
|
218
|
-
*/
|
|
219
384
|
ensureConfig(): Promise<void>;
|
|
220
385
|
/**
|
|
221
|
-
*
|
|
386
|
+
* Standard InnerTube request using the WEB client (useful for authenticated endpoints).
|
|
222
387
|
*/
|
|
223
388
|
request(endpoint: string, payload: any): Promise<any>;
|
|
224
389
|
/**
|
|
225
|
-
*
|
|
390
|
+
* Specialized request for the /player endpoint that loops through client profiles
|
|
391
|
+
* to bypass IP blocks or Captcha walls.
|
|
226
392
|
*/
|
|
393
|
+
requestPlayerWithFallback(videoId: string): Promise<any>;
|
|
227
394
|
search(query: string, options?: {
|
|
228
395
|
type?: 'video' | 'playlist' | 'channel' | 'all';
|
|
229
396
|
}): Promise<SearchResult>;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
getVideo(videoId: string): Promise<Video>;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
getPlaylist(playlistId: string): Promise<Playlist>;
|
|
397
|
+
findOne(query: string, options?: {
|
|
398
|
+
type?: 'video' | 'playlist' | 'channel' | 'all';
|
|
399
|
+
}): Promise<SearchItem | undefined>;
|
|
400
|
+
getVideo(videoId: string): Promise<Video | LiveVideo>;
|
|
401
|
+
getPlaylist(playlistId: string): Promise<Playlist | MixPlaylist>;
|
|
402
|
+
getChannel(channelId: string): Promise<Channel | undefined>;
|
|
403
|
+
getVideoTranscript(videoId: string, languageCode?: string): Promise<Caption[] | undefined>;
|
|
238
404
|
}
|
|
239
405
|
|
|
240
406
|
/**
|
|
241
|
-
*
|
|
242
|
-
* Scrapes YouTube
|
|
407
|
+
* scraper.ts
|
|
408
|
+
* Scrapes user-specific YouTube feeds: History, Likes, Watch Later, and Custom Playlists.
|
|
243
409
|
* Works client-side (Chrome extensions, desktop apps, or CORS-proxied environments).
|
|
244
410
|
*/
|
|
411
|
+
interface VideoEntry {
|
|
412
|
+
title: string;
|
|
413
|
+
channel: string;
|
|
414
|
+
}
|
|
415
|
+
interface CustomPlaylist {
|
|
416
|
+
url: string;
|
|
417
|
+
}
|
|
245
418
|
|
|
246
|
-
interface
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
publishedTime: string;
|
|
250
|
-
likeCount: number;
|
|
251
|
-
commentId: string;
|
|
419
|
+
interface CustomPlaylistData {
|
|
420
|
+
id: string;
|
|
421
|
+
entries: VideoEntry[];
|
|
252
422
|
}
|
|
253
|
-
interface
|
|
254
|
-
|
|
255
|
-
|
|
423
|
+
interface TasteData {
|
|
424
|
+
historyEntries: VideoEntry[];
|
|
425
|
+
likesEntries: VideoEntry[];
|
|
426
|
+
wlEntries: VideoEntry[];
|
|
427
|
+
dislikesEntries: VideoEntry[];
|
|
428
|
+
customPlaylistsData: CustomPlaylistData[];
|
|
256
429
|
}
|
|
257
430
|
/**
|
|
258
|
-
*
|
|
259
|
-
* @param
|
|
260
|
-
* @
|
|
261
|
-
* @returns Options with headers and stringified body.
|
|
431
|
+
* Fetches the HTML of a YouTube page and extracts `ytInitialData`.
|
|
432
|
+
* @param url - The URL to fetch.
|
|
433
|
+
* @returns The parsed ytInitialData object or null.
|
|
262
434
|
*/
|
|
263
|
-
declare function
|
|
435
|
+
declare function fetchYtInitialData(url: string): Promise<any>;
|
|
264
436
|
/**
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* @param
|
|
268
|
-
* @
|
|
269
|
-
* @returns Scraped comments.
|
|
437
|
+
* Recursively scans a JSON object to extract video entries { title, channel }.
|
|
438
|
+
* Handles both the legacy videoRenderer and the newer lockupViewModel schemas.
|
|
439
|
+
* @param data - The JSON object to search.
|
|
440
|
+
* @returns Array of extracted video entries.
|
|
270
441
|
*/
|
|
271
|
-
declare function
|
|
442
|
+
declare function extractVideoEntries(data: any): VideoEntry[];
|
|
443
|
+
/**
|
|
444
|
+
* Recursively searches for the continuation token in an InnerTube response.
|
|
445
|
+
* @param obj - InnerTube response subtree.
|
|
446
|
+
* @returns The token or null.
|
|
447
|
+
*/
|
|
448
|
+
declare function findContinuationToken(obj: any): string | null;
|
|
449
|
+
/**
|
|
450
|
+
* Fetches video list from a specific InnerTube browse ID, paginating if needed.
|
|
451
|
+
* @param apiKey - InnerTube API Key.
|
|
452
|
+
* @param clientVersion - InnerTube client version string.
|
|
453
|
+
* @param idToken - Identity Token.
|
|
454
|
+
* @param browseId - Target feed ID (e.g. 'FEhistory', 'VLLL', 'VLWL').
|
|
455
|
+
* @param limit - Maximum entries to fetch.
|
|
456
|
+
* @returns Array of videos.
|
|
457
|
+
*/
|
|
458
|
+
declare function fetchInnerTubeFeed(apiKey: string, clientVersion: string, idToken: string | null, browseId: string, limit?: number): Promise<VideoEntry[]>;
|
|
459
|
+
/**
|
|
460
|
+
* Scrapes History, Liked videos, Watch Later, and any custom playlists.
|
|
461
|
+
* Tries the InnerTube JSON API first, then falls back to HTML-scraping + paginating if needed.
|
|
462
|
+
* @param injectedConfig - Preconfigured InnerTube parameters.
|
|
463
|
+
* @param customPlaylists - Custom playlist definitions with URLs/IDs.
|
|
464
|
+
* @param limit - Maximum items to retrieve per feed.
|
|
465
|
+
* @returns Scraped feeds.
|
|
466
|
+
*/
|
|
467
|
+
declare function scrapeTasteData(injectedConfig?: Partial<InnerTubeConfig> | null, customPlaylists?: CustomPlaylist[], limit?: number): Promise<TasteData>;
|
|
272
468
|
|
|
273
469
|
/**
|
|
274
470
|
* subtitles.ts
|
|
275
471
|
* Scrapes and parses subtitles/transcripts for a YouTube video.
|
|
276
472
|
* Works client-side (Chrome extensions, desktop apps, or CORS-proxied environments) and server-side.
|
|
277
473
|
*/
|
|
474
|
+
|
|
278
475
|
interface TranscriptSegment {
|
|
279
476
|
start: number;
|
|
280
477
|
duration: number;
|
|
@@ -294,10 +491,93 @@ declare function extractPlayerResponse(html: string): any;
|
|
|
294
491
|
declare function parseXmlTranscriptRegex(xmlText: string): TranscriptSegment[];
|
|
295
492
|
/**
|
|
296
493
|
* Fetches and parses the subtitles/captions transcript for a video in the requested language.
|
|
494
|
+
* Uses InnerTube API with Client profiles fallback, and json3 extraction for better stability.
|
|
297
495
|
* @param videoId - The YouTube Video ID.
|
|
298
496
|
* @param language - The desired language code (e.g. 'en', 'it', 'es').
|
|
299
497
|
* @returns Array of transcript segments.
|
|
300
498
|
*/
|
|
301
|
-
declare function fetchSubtitlesFromYouTube(videoId: string, language?: string): Promise<TranscriptSegment[]>;
|
|
499
|
+
declare function fetchSubtitlesFromYouTube(videoId: string, language?: string, clientOrOptions?: Client | ClientOptions): Promise<TranscriptSegment[]>;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Convert transcript segments to SubRip (SRT) format.
|
|
503
|
+
*
|
|
504
|
+
* @param segments - Array of transcript segments.
|
|
505
|
+
* @returns A string in SRT format with sequence numbers and `HH:MM:SS,mmm` timestamps.
|
|
506
|
+
*/
|
|
507
|
+
declare function toSRT(segments: TranscriptSegment[]): string;
|
|
508
|
+
/**
|
|
509
|
+
* Convert transcript segments to WebVTT (VTT) format.
|
|
510
|
+
*
|
|
511
|
+
* @param segments - Array of transcript segments.
|
|
512
|
+
* @returns A string in VTT format with `WEBVTT` header and `HH:MM:SS.mmm` timestamps.
|
|
513
|
+
*/
|
|
514
|
+
declare function toVTT(segments: TranscriptSegment[]): string;
|
|
515
|
+
/**
|
|
516
|
+
* Convert transcript segments to plain text.
|
|
517
|
+
*
|
|
518
|
+
* @param segments - Array of transcript segments.
|
|
519
|
+
* @param separator - String to join segments with. Defaults to `'\n'`.
|
|
520
|
+
* @returns A plain text string with segments joined by the separator.
|
|
521
|
+
*/
|
|
522
|
+
declare function toPlainText(segments: TranscriptSegment[], separator?: string): string;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* comments.ts
|
|
526
|
+
* Scrapes YouTube video comments using InnerTube endpoints and HTML scraping.
|
|
527
|
+
* Works client-side (Chrome extensions, desktop apps, or CORS-proxied environments).
|
|
528
|
+
*/
|
|
529
|
+
|
|
530
|
+
interface CommentEntry {
|
|
531
|
+
author: string;
|
|
532
|
+
text: string;
|
|
533
|
+
publishedTime: string;
|
|
534
|
+
likeCount: number;
|
|
535
|
+
commentId: string;
|
|
536
|
+
}
|
|
537
|
+
interface CommentsApiRequestOptions {
|
|
538
|
+
headers: Record<string, string>;
|
|
539
|
+
body: string;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Creates options for the InnerTube /next API call to fetch comments.
|
|
543
|
+
* @param continuationToken - Continuation token for the next page of comments.
|
|
544
|
+
* @param clientVersion - YouTube client version.
|
|
545
|
+
* @returns Options with headers and stringified body.
|
|
546
|
+
*/
|
|
547
|
+
declare function createCommentsApiRequestOptions(continuationToken: string, clientVersion?: string): CommentsApiRequestOptions;
|
|
548
|
+
/**
|
|
549
|
+
* Fetches comment list for a YouTube video, paginating with continuation tokens.
|
|
550
|
+
* @param videoId - The YouTube Video ID.
|
|
551
|
+
* @param count - Number of comments to retrieve.
|
|
552
|
+
* @param injectedConfig - InnerTube config parameters.
|
|
553
|
+
* @returns Scraped comments.
|
|
554
|
+
*/
|
|
555
|
+
declare function fetchCommentsFromYouTube(videoId: string, count?: number, injectedConfig?: Partial<InnerTubeConfig> | null): Promise<CommentEntry[]>;
|
|
556
|
+
|
|
557
|
+
declare class Chat extends Base {
|
|
558
|
+
id: string;
|
|
559
|
+
message: string;
|
|
560
|
+
author: BaseChannel;
|
|
561
|
+
timestamp: number;
|
|
562
|
+
constructor(client: Client, data?: any);
|
|
563
|
+
load(data: any): Chat;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Convenience helper to search YouTube without initializing a Client manually.
|
|
568
|
+
* @param query The search query string.
|
|
569
|
+
* @param options ClientOptions & Search filtering options.
|
|
570
|
+
* @returns SearchResult object with video/playlist/channel items.
|
|
571
|
+
*/
|
|
572
|
+
declare function searchYouTube(query: string, options?: {
|
|
573
|
+
type?: 'video' | 'playlist' | 'channel' | 'all';
|
|
574
|
+
} & ClientOptions): Promise<SearchResult>;
|
|
575
|
+
/**
|
|
576
|
+
* Convenience helper to get a video's metadata and playback/streaming data.
|
|
577
|
+
* @param videoId The video ID.
|
|
578
|
+
* @param options ClientOptions (e.g. for proxy/fetch customization).
|
|
579
|
+
* @returns Video object with streamingData populated.
|
|
580
|
+
*/
|
|
581
|
+
declare function getVideoPlayback(videoId: string, options?: ClientOptions): Promise<Video | LiveVideo>;
|
|
302
582
|
|
|
303
|
-
export { Base, BaseVideo, ChannelCompact, type ChannelInfo, Client, type ClientOptions, type CommentEntry, type CommentsApiRequestOptions, Continuable, type CustomPlaylist, type CustomPlaylistData, type InnerTubeConfig, Playlist, PlaylistCompact, PlaylistVideos, type SearchItem, SearchResult, type TasteData, type Thumbnail, Thumbnails, type TranscriptSegment, Video, VideoCompact, type VideoEntry, createCommentsApiRequestOptions, extractPlayerResponse, extractVideoEntries, fetchCommentsFromYouTube, fetchInnerTubeFeed, fetchSubtitlesFromYouTube, fetchYtInitialData, findContinuationToken, getInnerTubeConfig, getSApiSidHash,
|
|
583
|
+
export { Base, BaseChannel, BaseVideo, type Cache, Caption, CaptionLanguage, Channel, ChannelCompact, type ChannelInfo, ChannelLive, ChannelPlaylists, ChannelPosts, ChannelShorts, ChannelVideos, Chat, Client, type ClientOptions, type ClientProfile, Comment, type CommentEntry, CommentReplies, type CommentsApiRequestOptions, Continuable, type CustomPlaylist, type CustomPlaylistData, type Format, type InnerTubeConfig, LiveVideo, MixPlaylist, Playlist, PlaylistCompact, PlaylistVideos, type SearchItem, SearchResult, type StreamingData, type TasteData, type Thumbnail, Thumbnails, type TranscriptSegment, Video, VideoCaptions, VideoComments, VideoCompact, type VideoEntry, VideoRelated, createCommentsApiRequestOptions, extractPlayerResponse, extractVideoEntries, fetchCommentsFromYouTube, fetchInnerTubeFeed, fetchSubtitlesFromYouTube, fetchYtInitialData, findContinuationToken, getInnerTubeConfig, getSApiSidHash, getSapisidFromCookieString, getVideoPlayback, parseXmlTranscriptRegex, scrapeTasteData, searchYouTube, toPlainText, toSRT, toVTT };
|