UNPKG

11.4 kBTypeScriptView Raw
1declare module 'ytdl-core' {
2 import { ClientRequest } from 'http';
3 import { Readable } from 'stream';
4
5 namespace ytdl {
6 type Filter = 'audioandvideo' | 'video' | 'videoonly' | 'audio' | 'audioonly' | ((format: videoFormat) => boolean);
7 type downloadOptions = {
8 quality?: 'lowest' | 'highest' | 'highestaudio' | 'lowestaudio' | 'highestvideo' | 'lowestvideo' | string | number;
9 filter?: Filter;
10 format?: videoFormat;
11 range?: {
12 start?: number;
13 end?: number;
14 };
15 begin?: string | number | Date;
16 liveBuffer?: number;
17 requestOptions?: {};
18 highWaterMark?: number;
19 lang?: string;
20 }
21
22 type videoFormat = {
23 itag: number;
24 url: string;
25 mimeType?: string;
26 bitrate?: number | string;
27 width?: number;
28 height?: number;
29 initRange?: { start: string; end: string };
30 indexRange?: { start: string; end: string };
31 lastModified: string;
32 contentLength: string;
33 quality: 'tiny' | 'small' | 'medium' | 'large' | 'hd720' | 'hd1080' | 'hd1440' | string;
34 qualityLabel: '144p' | '240p' | '270p' | '360p' | '480p' | '720p' | '1080p' | '1440p' | '2160p' | '4320p';
35 projectionType: 'RECTANGULAR';
36 fps?: number;
37 averageBitrate: number;
38 audioQuality?: 'AUDIO_QUALITY_LOW' | 'AUDIO_QUALITY_MEDIUM';
39 colorInfo?: {
40 primaries: string;
41 transferCharacteristics: string;
42 matrixCoefficients: string;
43 };
44 highReplication?: boolean;
45 approxDurationMs: string;
46 audioSampleRate?: string;
47 audioChannels?: number;
48
49 // Added by ytdl-core
50 container: 'flv' | '3gp' | 'mp4' | 'webm' | 'ts';
51 codecs: string;
52
53 live: boolean;
54 isHLS: boolean;
55 isDashMPD: boolean;
56 }
57
58 type thumbnail = {
59 url: string;
60 width: number;
61 height: number;
62 }
63
64 type captionTrack = {
65 baseUrl: string;
66 name: {
67 simpleText: 'Afrikaans' | 'Albanian' | 'Amharic' | 'Arabic' | 'Armenian' | 'Azerbaijani' | 'Bangla' | 'Basque' | 'Belarusian' | 'Bosnian' | 'Bulgarian' | 'Burmese' | 'Catalan' | 'Cebuano' | 'Chinese (Simplified)' | 'Chinese (Traditional)' | 'Corsican' | 'Croatian' | 'Czech' | 'Danish' | 'Dutch' | 'English' | 'English (auto-generated)' | 'Esperanto' | 'Estonian' | 'Filipino' | 'Finnish' | 'French' | 'Galician' | 'Georgian' | 'German' | 'Greek' | 'Gujarati' | 'Haitian Creole' | 'Hausa' | 'Hawaiian' | 'Hebrew' | 'Hindi' | 'Hmong' | 'Hungarian' | 'Icelandic' | 'Igbo' | 'Indonesian' | 'Irish' | 'Italian' | 'Japanese' | 'Javanese' | 'Kannada' | 'Kazakh' | 'Khmer' | 'Korean' | 'Kurdish' | 'Kyrgyz' | 'Lao' | 'Latin' | 'Latvian' | 'Lithuanian' | 'Luxembourgish' | 'Macedonian' | 'Malagasy' | 'Malay' | 'Malayalam' | 'Maltese' | 'Maori' | 'Marathi' | 'Mongolian' | 'Nepali' | 'Norwegian' | 'Nyanja' | 'Pashto' | 'Persian' | 'Polish' | 'Portuguese' | 'Punjabi' | 'Romanian' | 'Russian' | 'Samoan' | 'Scottish Gaelic' | 'Serbian' | 'Shona' | 'Sindhi' | 'Sinhala' | 'Slovak' | 'Slovenian' | 'Somali' | 'Southern Sotho' | 'Spanish' | 'Spanish (Spain)' | 'Sundanese' | 'Swahili' | 'Swedish' | 'Tajik' | 'Tamil' | 'Telugu' | 'Thai' | 'Turkish' | 'Ukrainian' | 'Urdu' | 'Uzbek' | 'Vietnamese' | 'Welsh' | 'Western Frisian' | 'Xhosa' | 'Yiddish' | 'Yoruba' | 'Zulu' | string;
68 };
69 vssId: string;
70 languageCode: 'af' | 'sq' | 'am' | 'ar' | 'hy' | 'az' | 'bn' | 'eu' | 'be' | 'bs' | 'bg' | 'my' | 'ca' | 'ceb' | 'zh-Hans' | 'zh-Hant' | 'co' | 'hr' | 'cs' | 'da' | 'nl' | 'en' | 'eo' | 'et' | 'fil' | 'fi' | 'fr' | 'gl' | 'ka' | 'de' | 'el' | 'gu' | 'ht' | 'ha' | 'haw' | 'iw' | 'hi' | 'hmn' | 'hu' | 'is' | 'ig' | 'id' | 'ga' | 'it' | 'ja' | 'jv' | 'kn' | 'kk' | 'km' | 'ko' | 'ku' | 'ky' | 'lo' | 'la' | 'lv' | 'lt' | 'lb' | 'mk' | 'mg' | 'ms' | 'ml' | 'mt' | 'mi' | 'mr' | 'mn' | 'ne' | 'no' | 'ny' | 'ps' | 'fa' | 'pl' | 'pt' | 'pa' | 'ro' | 'ru' | 'sm' | 'gd' | 'sr' | 'sn' | 'sd' | 'si' | 'sk' | 'sl' | 'so' | 'st' | 'es' | 'su' | 'sw' | 'sv' | 'tg' | 'ta' | 'te' | 'th' | 'tr' | 'uk' | 'ur' | 'uz' | 'vi' | 'cy' | 'fy' | 'xh' | 'yi' | 'yo' | 'zu' | string;
71 kind: string;
72 rtl?: boolean;
73 isTranslatable: boolean;
74 }
75
76 type videoInfo = {
77 iv_load_policy?: string;
78 iv_allow_in_place_switch?: string;
79 iv_endscreen_url?: string;
80 iv_invideo_url?: string;
81 iv3_module?: string;
82 rmktEnabled?: string;
83 uid?: string;
84 vid?: string;
85 focEnabled?: string;
86 baseUrl?: string;
87 storyboard_spec?: string;
88 serialized_ad_ux_config?: string;
89 player_error_log_fraction?: string;
90 sffb?: string;
91 ldpj?: string;
92 videostats_playback_base_url?: string;
93 innertube_context_client_version?: string;
94 t?: string;
95 fade_in_start_milliseconds: string;
96 timestamp: string;
97 ad3_module: string;
98 relative_loudness: string;
99 allow_below_the_player_companion: string;
100 eventid: string;
101 token: string;
102 atc: string;
103 title: string;
104 cr: string;
105 apply_fade_on_midrolls: string;
106 cl: string;
107 fexp: string[];
108 apiary_host: string;
109 fade_in_duration_milliseconds: string;
110 fflags: string;
111 ssl: string;
112 pltype: string;
113 media: {
114 image?: string;
115 category: string;
116 category_url: string;
117 game?: string;
118 game_url?: string;
119 year?: number;
120 song?: string;
121 artist?: string;
122 artist_url?: string;
123 writers?: string;
124 licensed_by?: string;
125 };
126 author: {
127 id: string;
128 name: string;
129 avatar: string;
130 verified: boolean;
131 user: string;
132 channel_url: string;
133 user_url: string;
134 };
135 enabled_engage_types: string;
136 hl: string;
137 is_listed: string;
138 gut_tag: string;
139 apiary_host_firstparty: string;
140 enablecsi: string;
141 csn: string;
142 status: string;
143 afv_ad_tag: string;
144 idpj: string;
145 sfw_player_response: string;
146 account_playback_token: string;
147 encoded_ad_safety_reason: string;
148 tag_for_children_directed: string;
149 no_get_video_log: string;
150 ppv_remarketing_url: string;
151 fmt_list: string[][];
152 ad_slots: string;
153 fade_out_duration_milliseconds: string;
154 instream_long: string;
155 allow_html5_ads: string;
156 core_dbp: string;
157 ad_device: string;
158 itct: string;
159 root_ve_type: string;
160 excluded_ads: string;
161 aftv: string;
162 loeid: string;
163 cver: string;
164 shortform: string;
165 dclk: string;
166 csi_page_type: string;
167 ismb: string;
168 gpt_migration: string;
169 loudness: string;
170 ad_tag: string;
171 of: string;
172 probe_url: string;
173 vm: string;
174 afv_ad_tag_restricted_to_instream: string;
175 gapi_hint_params: string;
176 cid: string;
177 c: string;
178 oid: string;
179 ptchn: string;
180 as_launched_in_country: string;
181 avg_rating: string;
182 fade_out_start_milliseconds: string;
183 length_seconds: string;
184 midroll_prefetch_size: string;
185 allow_ratings: string;
186 thumbnail_url: string;
187 iurlsd: string;
188 iurlmq: string;
189 iurlhq: string;
190 iurlmaxres: string;
191 ad_preroll: string;
192 tmi: string;
193 trueview: string;
194 host_language: string;
195 innertube_api_key: string;
196 show_content_thumbnail: string;
197 afv_instream_max: string;
198 innertube_api_version: string;
199 mpvid: string;
200 allow_embed: string;
201 ucid: string;
202 plid: string;
203 midroll_freqcap: string;
204 ad_logging_flag: string;
205 ptk: string;
206 vmap: string;
207 watermark: string[];
208 video_id: string;
209 dbp: string;
210 ad_flags: string;
211 html5player: string;
212 formats: videoFormat[];
213 published: number;
214 description: string;
215 related_videos: relatedVideo[];
216 video_url: string;
217 no_embed_allowed?: boolean;
218 age_restricted: boolean;
219 likes?: number;
220 dislikes?: number;
221 player_response: {
222 playabilityStatus: {
223 status: string;
224 };
225 streamingData: {
226 expiresInSeconds: string;
227 formats: {}[];
228 adaptiveFormats: {}[];
229 };
230 captions?: {
231 playerCaptionsTracklistRenderer: {
232 captionTracks: captionTrack[];
233 };
234 };
235 microformat: {
236 playerMicroformatRenderer: {
237 thumbnail: {
238 thumbnails: thumbnail[];
239 };
240 embed: {
241 iframeUrl: string;
242 flashUrl: string;
243 width: number;
244 height: number;
245 flashSecureUrl: string;
246 };
247 title: {
248 simpleText: string;
249 };
250 description: {
251 simpleText: string;
252 };
253 lengthSeconds: string;
254 ownerProfileUrl: string;
255 ownerGplusProfileUrl: string;
256 externalChannelId: string;
257 isFamilySafe: boolean;
258 availableCountries: string[];
259 isUnlisted: boolean;
260 hasYpcMetadata: boolean;
261 viewCount: string;
262 category: string;
263 publishDate: string;
264 ownerChannelName: string;
265 uploadDate: string;
266 };
267 };
268 videoDetails: {
269 videoId: string;
270 title: string;
271 lengthSeconds: number;
272 keywords: string[];
273 channelId: string;
274 isCrawlable: boolean;
275 thumbnail: {
276 thumbnails: thumbnail[];
277 };
278 viewCount: number;
279 author: string;
280 isLiveContent: boolean;
281 };
282 };
283 }
284
285 type relatedVideo = {
286 id?: string;
287 title?: string;
288 author?: string;
289 length_seconds?: string;
290 iurlmq?: string;
291 short_view_count_text?: string;
292 session_data: string;
293 endscreen_autoplay_session_data?: string;
294 iurlhq?: string;
295 playlist_iurlhq?: string;
296 playlist_title?: string;
297 playlist_length?: string;
298 playlist_iurlmq?: string;
299 video_id?: string;
300 list?: string;
301 thumbnail_ids?: string;
302 }
303
304 function getBasicInfo(url: string, callback?: (err: Error, info: videoInfo) => void): Promise<videoInfo>;
305 function getBasicInfo(url: string, options?: downloadOptions, callback?: (err: Error, info: videoInfo) => void): Promise<videoInfo>;
306 function getInfo(url: string, callback?: (err: Error, info: videoInfo) => void): Promise<videoInfo>;
307 function getInfo(url: string, options?: downloadOptions, callback?: (err: Error, info: videoInfo) => void): Promise<videoInfo>;
308 function downloadFromInfo(info: videoInfo, options?: downloadOptions): Readable;
309 function chooseFormat(format: videoFormat | videoFormat[], options?: downloadOptions): videoFormat | never;
310 function filterFormats(formats: videoFormat | videoFormat[], filter?: Filter): videoFormat[];
311 function validateID(string: string): boolean;
312 function validateURL(string: string): boolean;
313 function getURLVideoID(string: string): string | never;
314 function getVideoID(string: string): string | never;
315 }
316
317 function ytdl(link: string, options?: ytdl.downloadOptions): Readable;
318
319 export = ytdl;
320}
321
\No newline at end of file