cloud-ytdl 1.0.0-rc

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.
@@ -0,0 +1,488 @@
1
+ declare module 'ytdl-cloud' {
2
+ import { Readable } from 'stream';
3
+
4
+ type ExtendString<T extends string> = T | Omit<string, T>;
5
+ type VideoID = string;
6
+ type YouTubeURL = string;
7
+ type ITags = number[];
8
+ type ClientType = 'web' | 'ios' | 'android' | 'tv' | 'webEmbedded' | 'unknown';
9
+ type StreamType = 'hls' | 'dash' | 'progressive';
10
+ type QualitySelection = 'best' | 'worst' | number | string;
11
+
12
+ namespace ytdl {
13
+ type Filter = 'audioandvideo' | 'videoandaudio' | 'video' | 'videoonly' | 'audio' | 'audioonly' | ((format: videoFormat) => boolean);
14
+
15
+ interface getInfoOptions {
16
+ lang?: string;
17
+ requestCallback?: () => void;
18
+ requestOptions?: {
19
+ agent?: any;
20
+ dispatcher?: any;
21
+ headers?: Record<string, string>;
22
+ timeout?: number;
23
+ maxReconnects?: number;
24
+ maxRetries?: number;
25
+ backoff?: {
26
+ inc: number;
27
+ max: number;
28
+ };
29
+ [key: string]: any;
30
+ };
31
+ }
32
+
33
+ type ChooseFormatQuality = 'lowest' | 'highest' | 'highestaudio' | 'lowestaudio' | 'highestvideo' | 'lowestvideo';
34
+
35
+ interface chooseFormatOptions {
36
+ quality?: ExtendString<ChooseFormatQuality> | number | ExtendString<ChooseFormatQuality>[] | number[];
37
+ filter?: Filter;
38
+ format?: videoFormat;
39
+ }
40
+
41
+ interface downloadOptions extends getInfoOptions, chooseFormatOptions {
42
+ range?: {
43
+ start?: number;
44
+ end?: number;
45
+ };
46
+ begin?: string | number | Date;
47
+ liveBuffer?: number;
48
+ highWaterMark?: number;
49
+ IPv6Block?: string;
50
+ dlChunkSize?: number;
51
+ multiThread?: boolean;
52
+ maxThreads?: number;
53
+ minSizeForMultiThread?: number;
54
+ requestOptions?: {
55
+ agent?: any;
56
+ dispatcher?: any;
57
+ headers?: Record<string, string>;
58
+ timeout?: number;
59
+ [key: string]: any;
60
+ };
61
+ }
62
+
63
+ type VideoFormatQuality = 'tiny' | 'small' | 'medium' | 'large' | 'hd720' | 'hd1080' | 'hd1440' | 'hd2160' | 'highres';
64
+
65
+ interface videoFormat {
66
+ itag: number;
67
+ url: string;
68
+ mimeType?: string;
69
+ bitrate?: number;
70
+ audioBitrate?: number;
71
+ width?: number;
72
+ height?: number;
73
+ initRange?: { start: string; end: string };
74
+ indexRange?: { start: string; end: string };
75
+ lastModified: string;
76
+ contentLength: string;
77
+ quality: ExtendString<VideoFormatQuality>;
78
+ qualityLabel: '144p' | '144p 15fps' | '144p60 HDR' | '240p' | '240p60 HDR' | '270p' | '360p' | '360p60 HDR'
79
+ | '480p' | '480p60 HDR' | '720p' | '720p60' | '720p60 HDR' | '1080p' | '1080p60' | '1080p60 HDR' | '1440p'
80
+ | '1440p60' | '1440p60 HDR' | '2160p' | '2160p60' | '2160p60 HDR' | '4320p' | '4320p60';
81
+ projectionType?: 'RECTANGULAR';
82
+ fps?: number;
83
+ averageBitrate?: number;
84
+ audioQuality?: 'AUDIO_QUALITY_LOW' | 'AUDIO_QUALITY_MEDIUM';
85
+ colorInfo?: {
86
+ primaries: string;
87
+ transferCharacteristics: string;
88
+ matrixCoefficients: string;
89
+ };
90
+ highReplication?: boolean;
91
+ approxDurationMs?: string;
92
+ targetDurationSec?: number;
93
+ maxDvrDurationSec?: number;
94
+ audioSampleRate?: string;
95
+ audioChannels?: number;
96
+
97
+ container: 'flv' | '3gp' | 'mp4' | 'webm' | 'ts' | 'unknown';
98
+ hasVideo: boolean;
99
+ hasAudio: boolean;
100
+ codecs: string;
101
+ videoCodec?: string;
102
+ audioCodec?: string;
103
+ isLive: boolean;
104
+ isHLS: boolean;
105
+ isDashMPD: boolean;
106
+ client?: ClientType;
107
+ signatureCipher?: string;
108
+ cipher?: string;
109
+ }
110
+
111
+ interface thumbnail {
112
+ url: string;
113
+ width: number;
114
+ height: number;
115
+ }
116
+
117
+ type CaptionTrackSimpleText = 'Afrikaans' | 'Albanian' | 'Amharic' | 'Arabic' | 'Armenian' | 'Azerbaijani' | 'Bangla' | 'Basque'
118
+ | 'Belarusian' | 'Bosnian' | 'Bulgarian' | 'Burmese' | 'Catalan' | 'Cebuano' | 'Chinese (Simplified)'
119
+ | 'Chinese (Traditional)' | 'Corsican' | 'Croatian' | 'Czech' | 'Danish' | 'Dutch' | 'English'
120
+ | 'English (auto-generated)' | 'Esperanto' | 'Estonian' | 'Filipino' | 'Finnish' | 'French' | 'Galician'
121
+ | 'Georgian' | 'German' | 'Greek' | 'Gujarati' | 'Haitian Creole' | 'Hausa' | 'Hawaiian' | 'Hebrew' | 'Hindi'
122
+ | 'Hmong' | 'Hungarian' | 'Icelandic' | 'Igbo' | 'Indonesian' | 'Irish' | 'Italian' | 'Japanese' | 'Javanese'
123
+ | 'Kannada' | 'Kazakh' | 'Khmer' | 'Korean' | 'Kurdish' | 'Kyrgyz' | 'Lao' | 'Latin' | 'Latvian' | 'Lithuanian'
124
+ | 'Luxembourgish' | 'Macedonian' | 'Malagasy' | 'Malay' | 'Malayalam' | 'Maltese' | 'Maori' | 'Marathi'
125
+ | 'Mongolian' | 'Nepali' | 'Norwegian' | 'Nyanja' | 'Pashto' | 'Persian' | 'Polish' | 'Portuguese' | 'Punjabi'
126
+ | 'Romanian' | 'Russian' | 'Samoan' | 'Scottish Gaelic' | 'Serbian' | 'Shona' | 'Sindhi' | 'Sinhala' | 'Slovak'
127
+ | 'Slovenian' | 'Somali' | 'Southern Sotho' | 'Spanish' | 'Spanish (Spain)' | 'Sundanese' | 'Swahili'
128
+ | 'Swedish' | 'Tajik' | 'Tamil' | 'Telugu' | 'Thai' | 'Turkish' | 'Ukrainian' | 'Urdu' | 'Uzbek' | 'Vietnamese'
129
+ | 'Welsh' | 'Western Frisian' | 'Xhosa' | 'Yiddish' | 'Yoruba' | 'Zulu';
130
+
131
+ type CaptionTrackLanguageCode = 'af' | 'sq' | 'am' | 'ar' | 'hy' | 'az' | 'bn' | 'eu' | 'be' | 'bs' | 'bg' | 'my' | 'ca' | 'ceb'
132
+ | 'zh-Hans' | 'zh-Hant' | 'co' | 'hr' | 'cs' | 'da' | 'nl' | 'en' | 'eo' | 'et' | 'fil' | 'fi' | 'fr' | 'gl'
133
+ | 'ka' | 'de' | 'el' | 'gu' | 'ht' | 'ha' | 'haw' | 'iw' | 'hi' | 'hmn' | 'hu' | 'is' | 'ig' | 'id' | 'ga' | 'it'
134
+ | 'ja' | 'jv' | 'kn' | 'kk' | 'km' | 'ko' | 'ku' | 'ky' | 'lo' | 'la' | 'lv' | 'lt' | 'lb' | 'mk' | 'mg' | 'ms'
135
+ | 'ml' | 'mt' | 'mi' | 'mr' | 'mn' | 'ne' | 'no' | 'ny' | 'ps' | 'fa' | 'pl' | 'pt' | 'pa' | 'ro' | 'ru' | 'sm'
136
+ | 'gd' | 'sr' | 'sn' | 'sd' | 'si' | 'sk' | 'sl' | 'so' | 'st' | 'es' | 'su' | 'sw' | 'sv' | 'tg' | 'ta' | 'te'
137
+ | 'th' | 'tr' | 'uk' | 'ur' | 'uz' | 'vi' | 'cy' | 'fy' | 'xh' | 'yi' | 'yo' | 'zu';
138
+
139
+ interface captionTrack {
140
+ baseUrl: string;
141
+ name: {
142
+ simpleText: ExtendString<CaptionTrackSimpleText>;
143
+ };
144
+ vssId: string;
145
+ languageCode: ExtendString<CaptionTrackLanguageCode>;
146
+ kind: string;
147
+ rtl?: boolean;
148
+ isTranslatable: boolean;
149
+ }
150
+
151
+ interface audioTrack {
152
+ captionTrackIndices: number[];
153
+ }
154
+
155
+ interface translationLanguage {
156
+ languageCode: captionTrack['languageCode'];
157
+ languageName: captionTrack['name'];
158
+ }
159
+
160
+ interface VideoDetails {
161
+ videoId: string;
162
+ title: string;
163
+ shortDescription: string;
164
+ lengthSeconds: string;
165
+ keywords?: string[];
166
+ channelId: string;
167
+ isOwnerViewing: boolean;
168
+ isCrawlable: boolean;
169
+ thumbnails: thumbnail[];
170
+ averageRating: number;
171
+ allowRatings: boolean;
172
+ viewCount: string;
173
+ author: string;
174
+ isPrivate: boolean;
175
+ isUnpluggedCorpus: boolean;
176
+ isLiveContent: boolean;
177
+ }
178
+
179
+ interface Media {
180
+ category: string;
181
+ category_url: string;
182
+ game?: string;
183
+ game_url?: string;
184
+ year?: number;
185
+ song?: string;
186
+ artist?: string;
187
+ artist_url?: string;
188
+ writers?: string;
189
+ licensed_by?: string;
190
+ thumbnails: thumbnail[];
191
+ }
192
+
193
+ interface Author {
194
+ id: string;
195
+ name: string;
196
+ avatar: string;
197
+ thumbnails?: thumbnail[];
198
+ verified: boolean;
199
+ user?: string;
200
+ channel_url: string;
201
+ external_channel_url?: string;
202
+ user_url?: string;
203
+ subscriber_count?: number;
204
+ }
205
+ interface YTPostPollOption {
206
+ text: string
207
+ votes: number
208
+ isCorrect?: boolean
209
+ }
210
+
211
+ interface YTPostPoll {
212
+ totalVotes: number
213
+ options: YTPostPollOption[]
214
+ }
215
+
216
+ interface YTPostInfo {
217
+ postId: string
218
+ author: string
219
+ authorUrl: string
220
+ published: string
221
+ content: string
222
+ images: string[]
223
+ likes: string
224
+ poll?: YTPostPoll
225
+ }
226
+
227
+
228
+ interface MicroformatRenderer {
229
+ thumbnail: {
230
+ thumbnails: thumbnail[];
231
+ };
232
+ embed: {
233
+ iframeUrl: string;
234
+ flashUrl: string;
235
+ width: number;
236
+ height: number;
237
+ flashSecureUrl: string;
238
+ };
239
+ title: {
240
+ simpleText: string;
241
+ };
242
+ description: {
243
+ simpleText: string;
244
+ };
245
+ lengthSeconds: string;
246
+ ownerProfileUrl: string;
247
+ ownerGplusProfileUrl?: string;
248
+ externalChannelId: string;
249
+ isFamilySafe: boolean;
250
+ availableCountries: string[];
251
+ isUnlisted: boolean;
252
+ hasYpcMetadata: boolean;
253
+ viewCount: string;
254
+ category: string;
255
+ publishDate: string;
256
+ ownerChannelName: string;
257
+ liveBroadcastDetails?: {
258
+ isLiveNow: boolean;
259
+ startTimestamp: string;
260
+ endTimestamp?: string;
261
+ };
262
+ uploadDate: string;
263
+ }
264
+
265
+ interface storyboard {
266
+ templateUrl: string;
267
+ thumbnailWidth: number;
268
+ thumbnailHeight: number;
269
+ thumbnailCount: number;
270
+ interval: number;
271
+ columns: number;
272
+ rows: number;
273
+ storyboardCount: number;
274
+ }
275
+
276
+ interface Chapter {
277
+ title: string;
278
+ start_time: number;
279
+ }
280
+
281
+ interface MoreVideoDetails extends Omit<VideoDetails, 'author' | 'thumbnail' | 'shortDescription'>, Omit<MicroformatRenderer, 'title' | 'description'> {
282
+ published: number;
283
+ video_url: string;
284
+ age_restricted: boolean;
285
+ likes: number | null;
286
+ dislikes: number | null;
287
+ media: Media;
288
+ author: Author;
289
+ thumbnails: thumbnail[];
290
+ storyboards: storyboard[];
291
+ chapters: Chapter[];
292
+ description: string | null;
293
+ }
294
+
295
+ interface videoInfo {
296
+ iv_load_policy?: string;
297
+ iv_allow_in_place_switch?: string;
298
+ iv_endscreen_url?: string;
299
+ iv_invideo_url?: string;
300
+ iv3_module?: string;
301
+ rmktEnabled?: string;
302
+ uid?: string;
303
+ vid?: string;
304
+ focEnabled?: string;
305
+ baseUrl?: string;
306
+ storyboard_spec?: string;
307
+ serialized_ad_ux_config?: string;
308
+ player_error_log_fraction?: string;
309
+ sffb?: string;
310
+ ldpj?: string;
311
+ videostats_playback_base_url?: string;
312
+ innertube_context_client_version?: string;
313
+ t?: string;
314
+ fade_in_start_milliseconds: string;
315
+ timestamp: string;
316
+ ad3_module: string;
317
+ relative_loudness: string;
318
+ allow_below_the_player_companion: string;
319
+ eventid: string;
320
+ token: string;
321
+ atc: string;
322
+ cr: string;
323
+ apply_fade_on_midrolls: string;
324
+ cl: string;
325
+ fexp: string[];
326
+ apiary_host: string;
327
+ fade_in_duration_milliseconds: string;
328
+ fflags: string;
329
+ ssl: string;
330
+ pltype: string;
331
+ enabled_engage_types: string;
332
+ hl: string;
333
+ is_listed: string;
334
+ gut_tag: string;
335
+ apiary_host_firstparty: string;
336
+ enablecsi: string;
337
+ csn: string;
338
+ status: string;
339
+ afv_ad_tag: string;
340
+ idpj: string;
341
+ sfw_player_response: string;
342
+ account_playback_token: string;
343
+ encoded_ad_safety_reason: string;
344
+ tag_for_children_directed: string;
345
+ no_get_video_log: string;
346
+ ppv_remarketing_url: string;
347
+ fmt_list: string[][];
348
+ ad_slots: string;
349
+ fade_out_duration_milliseconds: string;
350
+ instream_long: string;
351
+ allow_html5_ads: string;
352
+ core_dbp: string;
353
+ ad_device: string;
354
+ itct: string;
355
+ root_ve_type: string;
356
+ excluded_ads: string;
357
+ aftv: string;
358
+ loeid: string;
359
+ cver: string;
360
+ shortform: string;
361
+ dclk: string;
362
+ csi_page_type: string;
363
+ ismb: string;
364
+ gpt_migration: string;
365
+ loudness: string;
366
+ ad_tag: string;
367
+ of: string;
368
+ probe_url: string;
369
+ vm: string;
370
+ afv_ad_tag_restricted_to_instream: string;
371
+ gapi_hint_params: string;
372
+ cid: string;
373
+ c: string;
374
+ oid: string;
375
+ ptchn: string;
376
+ as_launched_in_country: string;
377
+ avg_rating: string;
378
+ fade_out_start_milliseconds: string;
379
+ midroll_prefetch_size: string;
380
+ allow_ratings: string;
381
+ thumbnail_url: string;
382
+ iurlsd: string;
383
+ iurlmq: string;
384
+ iurlhq: string;
385
+ iurlmaxres: string;
386
+ ad_preroll: string;
387
+ tmi: string;
388
+ trueview: string;
389
+ host_language: string;
390
+ innertube_api_key: string;
391
+ show_content_thumbnail: string;
392
+ afv_instream_max: string;
393
+ innertube_api_version: string;
394
+ mpvid: string;
395
+ allow_embed: string;
396
+ ucid: string;
397
+ plid: string;
398
+ midroll_freqcap: string;
399
+ ad_logging_flag: string;
400
+ ptk: string;
401
+ vmap: string;
402
+ watermark: string[];
403
+ dbp: string;
404
+ ad_flags: string;
405
+ html5player: string;
406
+ formats: videoFormat[];
407
+ related_videos: relatedVideo[];
408
+ no_embed_allowed?: boolean;
409
+ player_response: {
410
+ playabilityStatus: {
411
+ status: string;
412
+ playableInEmbed: boolean;
413
+ miniplayer: {
414
+ miniplayerRenderer: {
415
+ playbackMode: string;
416
+ };
417
+ };
418
+ contextParams: string;
419
+ };
420
+ streamingData: {
421
+ expiresInSeconds: string;
422
+ formats: {}[];
423
+ adaptiveFormats: {}[];
424
+ };
425
+ captions?: {
426
+ playerCaptionsRenderer: {
427
+ baseUrl: string;
428
+ visibility: string;
429
+ };
430
+ playerCaptionsTracklistRenderer: {
431
+ captionTracks: captionTrack[];
432
+ audioTracks: audioTrack[];
433
+ translationLanguages: translationLanguage[];
434
+ defaultAudioTrackIndex: number;
435
+ };
436
+ };
437
+ microformat: {
438
+ playerMicroformatRenderer: MicroformatRenderer;
439
+ };
440
+ videoDetails: VideoDetails;
441
+ playerConfig: {
442
+ audioConfig: {
443
+ loudnessDb: number;
444
+ perceptualLoudnessDb: number;
445
+ enablePerFormatLoudness: boolean;
446
+ };
447
+ streamSelectionConfig: { maxBitrate: string };
448
+ mediaCommonConfig: { dynamicReadaheadConfig: {}[] };
449
+ webPlayerConfig: { webPlayerActionsPorting: {}[] };
450
+ };
451
+ };
452
+ videoDetails: MoreVideoDetails;
453
+ }
454
+
455
+ interface relatedVideo {
456
+ id?: string;
457
+ title?: string;
458
+ published?: string;
459
+ author: Author | 'string';
460
+ ucid?: string;
461
+ author_thumbnail?: string;
462
+ short_view_count_text?: string;
463
+ view_count?: string;
464
+ length_seconds?: number;
465
+ video_thumbnail?: string;
466
+ thumbnails: thumbnail[];
467
+ richThumbnails: thumbnail[];
468
+ isLive: boolean;
469
+ }
470
+ function getPostInfo(url: string, options?: { lang?: string; headers?: Record<string, string> }): Promise<YTPostInfo>
471
+
472
+ function getBasicInfo(url: string, options?: getInfoOptions): Promise<videoInfo>;
473
+ function getInfo(url: string, options?: getInfoOptions): Promise<videoInfo>;
474
+ function downloadFromInfo(info: videoInfo, options?: downloadOptions): Readable;
475
+ function chooseFormat(formats: videoFormat[], options?: chooseFormatOptions): videoFormat | never;
476
+ function chooseFormat(format: videoFormat, options?: chooseFormatOptions): videoFormat | never;
477
+ function filterFormats(formats: videoFormat[], filter?: Filter): videoFormat[];
478
+ function validateID(string: string): boolean;
479
+ function validateURL(string: string): boolean;
480
+ function getURLVideoID(string: string): string | never;
481
+ function getVideoID(string: string): string | never;
482
+ const version: number;
483
+ }
484
+
485
+ function ytdl(link: string, options?: ytdl.downloadOptions): Readable;
486
+
487
+ export = ytdl;
488
+ }