@chilfish/gallery-dl-instagram 0.1.0 → 0.2.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/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as Extractor, B as HttpResponse, C as InstagramUser, D as ParserConfig, E as ParsedPost, F as Config, G as RequestConfig, H as MessageIter, I as ConfigValue, K as Storage, L as DirectoryMsg, M as Logger, N as noopLogger, O as TaggedUser, P as ConfigManager, R as ExtractorClass, S as InstagramPost, T as ParsedMedia, U as Metadata, V as Message, W as QueueMsg, _ as InstagramRestAPI, a as InstagramHighlightsExtractor, b as InstagramCarouselItem, c as InstagramPostsExtractor, d as InstagramStoriesExtractor, f as InstagramTagExtractor, g as InstagramExtractorOptions, h as InstagramExtractor, i as InstagramAvatarExtractor, j as ExtractorOptions, k as VideoVersion, l as InstagramReelsExtractor, m as InstagramUserExtractor, n as InstagramSDK, o as InstagramInfoExtractor, p as InstagramTaggedExtractor, q as UrlMsg, r as SDKOptions, s as InstagramPostExtractor, t as ExtractOptions, u as InstagramSavedExtractor, v as Coauthor, w as MusicSticker, x as InstagramLocation, y as ImageCandidate, z as HttpClient } from "./sdk-B9fRyc1e.mjs";
1
+ import { _ as Metadata, a as ExtractorOptions, b as Storage, c as ConfigManager, d as DirectoryMsg, f as ExtractorClass, g as MessageIter, h as Message, i as Extractor, l as Config, m as HttpResponse, n as InstagramSDK, o as Logger, p as HttpClient, r as SDKOptions, s as noopLogger, t as ExtractOptions, u as ConfigValue, v as QueueMsg, x as UrlMsg, y as RequestConfig } from "./sdk-CK9x5wFL.mjs";
2
2
 
3
- //#region core/job.d.ts
3
+ //#region src/core/job.d.ts
4
4
  declare abstract class Job {
5
5
  readonly extractor: Extractor;
6
6
  status: number;
@@ -67,7 +67,470 @@ declare class PrintJob extends Job {
67
67
  protected _report(): void;
68
68
  }
69
69
  //#endregion
70
- //#region instagram/parsers.d.ts
70
+ //#region src/instagram/types.d.ts
71
+ /**
72
+ * Instagram API & parsed-post type definitions.
73
+ *
74
+ * These mirror the actual JSON shapes returned by Instagram's internal API
75
+ * (``/api/v1/…``).
76
+ */
77
+ /** API response types */
78
+ interface InstagramUser {
79
+ pk: string;
80
+ id?: string;
81
+ username: string;
82
+ full_name: string;
83
+ is_private?: boolean;
84
+ profile_pic_url?: string;
85
+ profile_pic_url_hd?: string;
86
+ hd_profile_pic_url_info?: ImageCandidate;
87
+ hd_profile_pic_versions?: ImageCandidate[];
88
+ profile_pic_id?: string;
89
+ edge_owner_to_timeline_media?: {
90
+ count: number;
91
+ };
92
+ edge_felix_video_timeline?: {
93
+ count: number;
94
+ };
95
+ edge_saved_media?: {
96
+ count: number;
97
+ };
98
+ edge_mutual_followed_by?: {
99
+ count: number;
100
+ };
101
+ edge_follow?: {
102
+ count: number;
103
+ };
104
+ edge_followed_by?: {
105
+ count: number;
106
+ };
107
+ edge_media_collections?: {
108
+ count: number;
109
+ };
110
+ followed_by_viewer?: boolean;
111
+ }
112
+ interface ImageCandidate {
113
+ url: string;
114
+ width: number;
115
+ height: number;
116
+ }
117
+ interface VideoVersion {
118
+ url: string;
119
+ width: number;
120
+ height: number;
121
+ type: number;
122
+ }
123
+ interface InstagramLocation {
124
+ pk: string;
125
+ short_name: string;
126
+ }
127
+ interface Caption {
128
+ text: string;
129
+ }
130
+ interface UserTag {
131
+ user: InstagramUser;
132
+ }
133
+ interface ReelMention {
134
+ user: InstagramUser;
135
+ }
136
+ interface BloksSticker {
137
+ bloks_sticker: {
138
+ bloks_sticker_type: string;
139
+ sticker_data: {
140
+ ig_mention: {
141
+ account_id: string;
142
+ username: string;
143
+ full_name: string;
144
+ };
145
+ };
146
+ };
147
+ }
148
+ interface MusicSticker {
149
+ music_asset_info?: MusicAssetInfo;
150
+ music_consumption_info?: MusicConsumptionInfo;
151
+ }
152
+ interface MusicAssetInfo {
153
+ id: string;
154
+ title?: string;
155
+ display_artist?: string;
156
+ ig_artist?: string;
157
+ duration_in_ms?: number;
158
+ highlight_start_times_in_ms?: number[];
159
+ progressive_download_url: string;
160
+ cover_artwork_uri?: string;
161
+ }
162
+ interface MusicConsumptionInfo {
163
+ display_artist?: string;
164
+ ig_artist?: string;
165
+ }
166
+ interface MusicMetadata {
167
+ music_info?: MusicAssetInfo;
168
+ }
169
+ interface InstagramPost {
170
+ pk: string;
171
+ id?: string;
172
+ code: string;
173
+ caption: Caption | null;
174
+ taken_at: number;
175
+ created_at?: number;
176
+ like_count?: number;
177
+ has_liked?: boolean;
178
+ user: InstagramUser;
179
+ carousel_media?: InstagramCarouselItem[];
180
+ image_versions2: {
181
+ candidates: ImageCandidate[];
182
+ };
183
+ video_versions?: VideoVersion[];
184
+ video_dash_manifest?: string;
185
+ original_width?: number;
186
+ original_height?: number;
187
+ media_type?: number;
188
+ original_media_type?: number;
189
+ location?: InstagramLocation;
190
+ coauthor_producers?: InstagramUser[];
191
+ usertags?: {
192
+ in: UserTag[];
193
+ };
194
+ reel_mentions?: ReelMention[];
195
+ story_bloks_stickers?: BloksSticker[];
196
+ story_music_stickers?: MusicSticker[];
197
+ music_metadata?: MusicMetadata;
198
+ expiring_at?: number;
199
+ seen?: number;
200
+ items?: InstagramCarouselItem[];
201
+ timeline_pinned_user_ids?: string[];
202
+ clips_tab_pinned_user_ids?: string[];
203
+ subscription_media_visibility?: string;
204
+ audience?: string;
205
+ title?: string;
206
+ pins?: unknown[];
207
+ }
208
+ interface InstagramCarouselItem {
209
+ pk: string;
210
+ id?: string;
211
+ code?: string;
212
+ taken_at?: number;
213
+ image_versions2: {
214
+ candidates: ImageCandidate[];
215
+ };
216
+ video_versions?: VideoVersion[];
217
+ video_dash_manifest?: string;
218
+ original_width?: number;
219
+ original_height?: number;
220
+ media_type?: number;
221
+ original_media_type?: number;
222
+ owner?: InstagramUser;
223
+ reshared_story_media_author?: InstagramUser;
224
+ expiring_at?: number;
225
+ subscription_media_visibility?: string;
226
+ audience?: string;
227
+ story_music_stickers?: MusicSticker[];
228
+ usertags?: {
229
+ in: UserTag[];
230
+ };
231
+ reel_mentions?: ReelMention[];
232
+ story_bloks_stickers?: BloksSticker[];
233
+ }
234
+ /** Parsed post (normalized output) */
235
+ interface ParsedPost {
236
+ post_id: string;
237
+ post_shortcode: string;
238
+ post_url: string;
239
+ owner_id: string;
240
+ username: string;
241
+ fullname: string;
242
+ post_date: string;
243
+ date: string;
244
+ description: string;
245
+ tags?: string[];
246
+ location_id?: string;
247
+ location_slug?: string;
248
+ location_url?: string;
249
+ likes: number;
250
+ liked: boolean;
251
+ pinned: string[];
252
+ coauthors?: Coauthor[];
253
+ sidecar_media_id?: string;
254
+ sidecar_shortcode?: string;
255
+ type: 'post' | 'reel' | 'story' | 'highlight';
256
+ count: number;
257
+ _files: ParsedMedia[];
258
+ user?: InstagramUser;
259
+ expires?: string;
260
+ highlight_title?: string;
261
+ tagged_owner_id?: string;
262
+ tagged_username?: string;
263
+ tagged_full_name?: string;
264
+ subscription?: string;
265
+ /** For graphql: */
266
+ typename?: string;
267
+ }
268
+ interface ParsedMedia {
269
+ num: number;
270
+ date: string;
271
+ media_id: string;
272
+ shortcode: string;
273
+ display_url: string;
274
+ video_url: string | null;
275
+ width: number;
276
+ width_original: number;
277
+ height: number;
278
+ height_original: number;
279
+ tagged_users: TaggedUser[];
280
+ owner?: InstagramUser;
281
+ author?: InstagramUser;
282
+ expires?: string;
283
+ subscription?: string;
284
+ audience?: string;
285
+ audio_url?: string;
286
+ audio_user?: string;
287
+ audio_title?: string;
288
+ audio_artist?: string;
289
+ audio_duration?: number;
290
+ audio_timestamps?: number[];
291
+ _ytdl_manifest_data?: string;
292
+ sidecar_media_id?: string;
293
+ sidecar_shortcode?: string;
294
+ }
295
+ interface Coauthor {
296
+ id: string;
297
+ username: string;
298
+ full_name?: string;
299
+ }
300
+ interface TaggedUser {
301
+ id: string;
302
+ username: string;
303
+ full_name: string;
304
+ }
305
+ /** Parser config */
306
+ interface ParserConfig {
307
+ root: string;
308
+ findTags: (text: string) => string[];
309
+ parseTimestamp: (ts: number | null | undefined) => string;
310
+ staticVideo: boolean;
311
+ warnVideo: boolean;
312
+ warnImage: number;
313
+ videosDash: boolean;
314
+ }
315
+ //#endregion
316
+ //#region src/instagram/api.d.ts
317
+ declare class InstagramRestAPI {
318
+ private readonly http;
319
+ private readonly root;
320
+ private readonly getCsrf;
321
+ private readonly getWwwClaim;
322
+ private readonly setWwwClaim;
323
+ private readonly setCsrf;
324
+ /** A ref to the extractor's cursor. */
325
+ private getCursor;
326
+ private setCursor;
327
+ constructor(opts: {
328
+ http: HttpClient;
329
+ root: string;
330
+ csrfToken: {
331
+ value: string;
332
+ };
333
+ wwwClaim: {
334
+ value: string;
335
+ };
336
+ cursor: {
337
+ value: string | null;
338
+ };
339
+ });
340
+ /** Public endpoint methods */
341
+ /** Single post by shortcode. */
342
+ media(shortcode: string): AsyncGenerator<InstagramPost>;
343
+ /** Paginated user feed. */
344
+ userFeed(userId: string): AsyncGenerator<InstagramPost>;
345
+ /** Paginated user reels (POST endpoint). */
346
+ userClips(userId: string): AsyncGenerator<InstagramPost>;
347
+ /** Paginated tagged posts. */
348
+ userTagged(userId: string): AsyncGenerator<InstagramPost>;
349
+ /** Paginated saved posts (media wrapper). */
350
+ userSaved(): AsyncGenerator<InstagramPost>;
351
+ /** Paginated collection. */
352
+ userCollection(collectionId: string): AsyncGenerator<InstagramPost>;
353
+ /** Reels media — batch call, returns full reel objects. */
354
+ reelsMedia(reelIds: string[]): Promise<InstagramPost[]>;
355
+ /** Story tray. */
356
+ reelsTray(): Promise<InstagramPost[]>;
357
+ /** Highlights list (tray). */
358
+ highlightsTray(userId: string): Promise<{
359
+ id: string;
360
+ }[]>;
361
+ /** All highlights' media batched by ``chunkSize``. */
362
+ highlightsMedia(userId: string, chunkSize?: number): AsyncGenerator<InstagramPost>;
363
+ /** Hashtag posts (via sections). */
364
+ tagsMedia(tag: string): AsyncGenerator<InstagramPost>;
365
+ private tagsSections;
366
+ /** User by numeric ID. */
367
+ userById(userId: string): Promise<InstagramUser>;
368
+ /** User by username (web_profile_info). */
369
+ userByName(username: string): Promise<InstagramUser>;
370
+ /** Search user by username. */
371
+ userBySearch(username: string): Promise<InstagramUser>;
372
+ /** Scrape user ID from HTML profile page. */
373
+ userByWeb(username: string): Promise<{
374
+ id: string;
375
+ }>;
376
+ /** Resolve screen name via fallback chain: search → info → web. */
377
+ userByScreenName(screenName: string): Promise<InstagramUser>;
378
+ /** Resolve username/id to numeric user ID string. */
379
+ userId(screenName: string, checkPrivate?: boolean): Promise<string>;
380
+ /** Followers (paginated). */
381
+ userFollowers(userId: string): AsyncGenerator<InstagramUser>;
382
+ /** Following (paginated). */
383
+ userFollowing(userId: string): AsyncGenerator<InstagramUser>;
384
+ /** Internal — HTTP call */
385
+ private _call;
386
+ /** Pagination engines */
387
+ private _pagination;
388
+ private _paginationPost;
389
+ private _paginationSections;
390
+ private _paginationFollowing;
391
+ private _parseIntCursor;
392
+ }
393
+ //#endregion
394
+ //#region src/instagram/base.d.ts
395
+ interface InstagramExtractorOptions extends ExtractorOptions {
396
+ sessionId?: string;
397
+ cookies?: Record<string, string>;
398
+ /** Pre-seeded CSRF token (from anonymous session cookie jar). */
399
+ csrfToken?: string;
400
+ }
401
+ declare class Ref<T> {
402
+ value: T;
403
+ constructor(v: T);
404
+ }
405
+ declare abstract class InstagramExtractor extends Extractor {
406
+ readonly category = "instagram";
407
+ readonly root = "https://www.instagram.com";
408
+ api: InstagramRestAPI;
409
+ csrfToken: Ref<string>;
410
+ wwwClaim: Ref<string>;
411
+ cursor: Ref<string | null>;
412
+ protected _loggedIn: boolean;
413
+ protected _user: InstagramUser | null;
414
+ private readonly _findTags;
415
+ private readonly _csrfSeed;
416
+ constructor(opts: InstagramExtractorOptions);
417
+ /** Initialization */
418
+ protected _init(): Promise<void>;
419
+ /** Request override */
420
+ request(url: string, cfg?: RequestConfig): Promise<HttpResponse<unknown>>;
421
+ /** Login */
422
+ login(): Promise<void>;
423
+ /** Core pipeline */
424
+ items(): MessageIter;
425
+ /** Subclass hooks */
426
+ /** @virtual */
427
+ metadata(): Promise<Record<string, unknown>>;
428
+ abstract posts(): AsyncGenerator<InstagramPost>;
429
+ /** Cursor management */
430
+ protected _initCursor(): string | null;
431
+ protected _updateCursor(cursor: string | null): string | null;
432
+ /** User assignment */
433
+ protected _assignUser(user: InstagramUser): void;
434
+ }
435
+ //#endregion
436
+ //#region src/instagram/extractors.d.ts
437
+ declare class InstagramPostExtractor extends InstagramExtractor {
438
+ static readonly subcategory = "post";
439
+ static pattern: RegExp;
440
+ readonly subcategory = "post";
441
+ constructor(opts: InstagramExtractorOptions);
442
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramPostExtractor | null;
443
+ posts(): AsyncGenerator<InstagramPost>;
444
+ }
445
+ declare class InstagramUserExtractor extends InstagramExtractor {
446
+ static readonly subcategory = "user";
447
+ static pattern: RegExp;
448
+ readonly subcategory = "user";
449
+ constructor(opts: InstagramExtractorOptions);
450
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramUserExtractor | null;
451
+ items(): MessageIter;
452
+ posts(): AsyncGenerator<InstagramPost>;
453
+ }
454
+ declare class InstagramPostsExtractor extends InstagramExtractor {
455
+ static readonly subcategory = "posts";
456
+ static pattern: RegExp;
457
+ readonly subcategory = "posts";
458
+ constructor(opts: InstagramExtractorOptions);
459
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramPostsExtractor | null;
460
+ posts(): AsyncGenerator<InstagramPost>;
461
+ }
462
+ declare class InstagramReelsExtractor extends InstagramExtractor {
463
+ static readonly subcategory = "reels";
464
+ static pattern: RegExp;
465
+ readonly subcategory = "reels";
466
+ constructor(opts: InstagramExtractorOptions);
467
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramReelsExtractor | null;
468
+ posts(): AsyncGenerator<InstagramPost>;
469
+ }
470
+ declare class InstagramTaggedExtractor extends InstagramExtractor {
471
+ static readonly subcategory = "tagged";
472
+ static pattern: RegExp;
473
+ readonly subcategory = "tagged";
474
+ private _taggedUserId;
475
+ constructor(opts: InstagramExtractorOptions);
476
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramTaggedExtractor | null;
477
+ metadata(): Promise<Record<string, unknown>>;
478
+ posts(): AsyncGenerator<InstagramPost>;
479
+ }
480
+ declare class InstagramStoriesExtractor extends InstagramExtractor {
481
+ static readonly subcategory = "stories";
482
+ static pattern: RegExp;
483
+ readonly subcategory = "stories";
484
+ private highlightId;
485
+ private mediaId;
486
+ constructor(opts: InstagramExtractorOptions);
487
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramStoriesExtractor | null;
488
+ posts(): AsyncGenerator<InstagramPost>;
489
+ }
490
+ declare class InstagramHighlightsExtractor extends InstagramExtractor {
491
+ static readonly subcategory = "highlights";
492
+ static pattern: RegExp;
493
+ readonly subcategory = "highlights";
494
+ constructor(opts: InstagramExtractorOptions);
495
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramHighlightsExtractor | null;
496
+ posts(): AsyncGenerator<InstagramPost>;
497
+ }
498
+ declare class InstagramTagExtractor extends InstagramExtractor {
499
+ static readonly subcategory = "tag";
500
+ static pattern: RegExp;
501
+ readonly subcategory = "tag";
502
+ constructor(opts: InstagramExtractorOptions);
503
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramTagExtractor | null;
504
+ metadata(): Promise<Record<string, unknown>>;
505
+ posts(): AsyncGenerator<InstagramPost>;
506
+ }
507
+ declare class InstagramInfoExtractor extends InstagramExtractor {
508
+ static readonly subcategory = "info";
509
+ static pattern: RegExp;
510
+ readonly subcategory = "info";
511
+ constructor(opts: InstagramExtractorOptions);
512
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramInfoExtractor | null;
513
+ items(): MessageIter;
514
+ posts(): AsyncGenerator<InstagramPost>;
515
+ }
516
+ declare class InstagramAvatarExtractor extends InstagramExtractor {
517
+ static readonly subcategory = "avatar";
518
+ static pattern: RegExp;
519
+ readonly subcategory = "avatar";
520
+ constructor(opts: InstagramExtractorOptions);
521
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramAvatarExtractor | null;
522
+ posts(): AsyncGenerator<InstagramPost>;
523
+ }
524
+ declare class InstagramSavedExtractor extends InstagramExtractor {
525
+ static readonly subcategory = "saved";
526
+ static pattern: RegExp;
527
+ readonly subcategory = "saved";
528
+ constructor(opts: InstagramExtractorOptions);
529
+ static fromURL(url: string, opts: InstagramExtractorOptions): InstagramSavedExtractor | null;
530
+ posts(): AsyncGenerator<InstagramPost>;
531
+ }
532
+ //#endregion
533
+ //#region src/instagram/parsers.d.ts
71
534
  /** Main entry — REST */
72
535
  declare function parsePostRest(post: InstagramPost, cfg: ParserConfig): ParsedPost;
73
536
  /** Tagged users */
@@ -77,14 +540,14 @@ declare function extractAudio(src: Record<string, unknown>, dest: Record<string,
77
540
  /** GraphQL parser */
78
541
  declare function parsePostGraphql(post: Record<string, unknown>, cfg: ParserConfig): ParsedPost;
79
542
  //#endregion
80
- //#region message.d.ts
543
+ //#region src/message.d.ts
81
544
  declare function directory(metadata?: Metadata): DirectoryMsg;
82
545
  declare function url(u: string, metadata?: Metadata): UrlMsg;
83
546
  declare function queue(u: string, metadata?: Metadata & {
84
547
  _extractor?: ExtractorClass;
85
548
  }): QueueMsg;
86
549
  //#endregion
87
- //#region utils/id-codec.d.ts
550
+ //#region src/utils/id-codec.d.ts
88
551
  /**
89
552
  * Instagram-style Base64-variant ID ↔ shortcode conversion.
90
553
  */
@@ -97,7 +560,7 @@ declare function idFromShortcode(shortcode: string): string;
97
560
  */
98
561
  declare function shortcodeFromId(postId: string | number): string;
99
562
  //#endregion
100
- //#region utils/text.d.ts
563
+ //#region src/utils/text.d.ts
101
564
  /**
102
565
  * Text utilities ported from gallery-dl's ``text`` module.
103
566
  *
@@ -140,48 +603,4 @@ declare function parseInt(value: string | number | null | undefined, default_?:
140
603
  /** Pre-configured hashtag regex. */
141
604
  declare const findTags: (text: string) => string[];
142
605
  //#endregion
143
- //#region index.d.ts
144
- /** Options for the Node.js convenience factory. */
145
- interface CreateSDKOptions {
146
- /**
147
- * Full browser Cookie header string.
148
- * Copy from DevTools → Network → Request Headers → Cookie.
149
- * Auto-extracts csrftoken for X-CSRFToken header.
150
- *
151
- * Either ``cookies`` or ``http`` must be provided.
152
- */
153
- cookies?: string;
154
- /**
155
- * Custom HttpClient implementation.
156
- * If omitted, a Node.js axios-based client is created from ``cookies``.
157
- */
158
- http?: HttpClient;
159
- /**
160
- * Custom Storage implementation for file output.
161
- * Defaults to Node.js fs/promises-based storage.
162
- */
163
- storage?: Storage;
164
- /**
165
- * Logger instance. Defaults to a silent no-op logger.
166
- */
167
- log?: Logger;
168
- }
169
- /**
170
- * Create an SDK instance with Node.js defaults.
171
- *
172
- * When ``cookies`` is provided, auto-creates an axios-based HttpClient
173
- * with CSRF token extraction. Pass ``http`` directly for custom adapters.
174
- *
175
- * ```ts
176
- * import { createSDK } from '@chilfish/gallery-dl-instagram'
177
- *
178
- * // Node.js with cookies
179
- * const ig = await createSDK({ cookies: 'ds_user_id=...; sessionid=...' })
180
- *
181
- * // Custom http adapter (browser / Deno / Edge)
182
- * const ig = await createSDK({ http: myHttpClient, storage: myStorage })
183
- * ```
184
- */
185
- declare function createSDK(opts?: CreateSDKOptions): Promise<InstagramSDK>;
186
- //#endregion
187
- export { type Coauthor, type Config, ConfigManager, type ConfigValue, CreateSDKOptions, type DirectoryMsg, DownloadJob, type ExtractOptions, Extractor, type ExtractorClass, type ExtractorOptions, type HttpClient, type HttpResponse, type ImageCandidate, InstagramAvatarExtractor, type InstagramCarouselItem, InstagramExtractor, type InstagramExtractorOptions, InstagramHighlightsExtractor, InstagramInfoExtractor, type InstagramLocation, type InstagramPost, InstagramPostExtractor, InstagramPostsExtractor, InstagramReelsExtractor, InstagramRestAPI, InstagramSDK, InstagramSavedExtractor, InstagramStoriesExtractor, InstagramTagExtractor, InstagramTaggedExtractor, type InstagramUser, InstagramUserExtractor, Job, type Logger, type Message, type MessageIter, type Metadata, type ParsedMedia, type ParsedPost, type ParserConfig, PrintJob, type QueueMsg, type RequestConfig, type SDKOptions, type Storage, type TaggedUser, type UrlMsg, type VideoVersion, createSDK, directory, ensureHttpScheme, extr, extract, extractAudio, extractTaggedUsers, findTags, idFromShortcode, nameExtFromURL, noopLogger, parseInt, parsePostGraphql, parsePostRest, parseUnicodeEscapes, queue, shortcodeFromId, unescape, unquote, url };
606
+ export { type Coauthor, type Config, ConfigManager, type ConfigValue, type DirectoryMsg, DownloadJob, type ExtractOptions, Extractor, type ExtractorClass, type ExtractorOptions, type HttpClient, type HttpResponse, type ImageCandidate, InstagramAvatarExtractor, type InstagramCarouselItem, InstagramExtractor, type InstagramExtractorOptions, InstagramHighlightsExtractor, InstagramInfoExtractor, type InstagramLocation, type InstagramPost, InstagramPostExtractor, InstagramPostsExtractor, InstagramReelsExtractor, InstagramRestAPI, InstagramSDK, InstagramSavedExtractor, InstagramStoriesExtractor, InstagramTagExtractor, InstagramTaggedExtractor, type InstagramUser, InstagramUserExtractor, Job, type Logger, type Message, type MessageIter, type Metadata, type ParsedMedia, type ParsedPost, type ParserConfig, PrintJob, type QueueMsg, type RequestConfig, type SDKOptions, type Storage, type TaggedUser, type UrlMsg, type VideoVersion, directory, ensureHttpScheme, extr, extract, extractAudio, extractTaggedUsers, findTags, idFromShortcode, nameExtFromURL, noopLogger, parseInt, parsePostGraphql, parsePostRest, parseUnicodeEscapes, queue, shortcodeFromId, unescape, unquote, url };
package/dist/index.mjs CHANGED
@@ -1,40 +1,2 @@
1
- import { a as extractCsrfFromCookies, r as createStorage, t as createHttpClient } from "./adapter-Bt86eL1R.mjs";
2
- import { A as idFromShortcode, C as parseUnicodeEscapes, D as queue, E as directory, F as ConfigManager, I as Extractor, L as noopLogger, M as DownloadJob, N as Job, O as url, P as PrintJob, S as parseInt, T as unquote, _ as ensureHttpScheme, a as InstagramPostsExtractor, b as findTags, c as InstagramStoriesExtractor, d as InstagramUserExtractor, f as InstagramExtractor, g as parsePostRest, h as parsePostGraphql, i as InstagramPostExtractor, j as shortcodeFromId, k as InstagramRestAPI, l as InstagramTagExtractor, m as extractTaggedUsers, n as InstagramHighlightsExtractor, o as InstagramReelsExtractor, p as extractAudio, r as InstagramInfoExtractor, s as InstagramSavedExtractor, t as InstagramAvatarExtractor, u as InstagramTaggedExtractor, v as extr, w as unescape, x as nameExtFromURL, y as extract } from "./extractors-Byw-2lPL.mjs";
3
- import { InstagramSDK } from "./sdk.mjs";
4
- //#region index.ts
5
- /**
6
- * Create an SDK instance with Node.js defaults.
7
- *
8
- * When ``cookies`` is provided, auto-creates an axios-based HttpClient
9
- * with CSRF token extraction. Pass ``http`` directly for custom adapters.
10
- *
11
- * ```ts
12
- * import { createSDK } from '@chilfish/gallery-dl-instagram'
13
- *
14
- * // Node.js with cookies
15
- * const ig = await createSDK({ cookies: 'ds_user_id=...; sessionid=...' })
16
- *
17
- * // Custom http adapter (browser / Deno / Edge)
18
- * const ig = await createSDK({ http: myHttpClient, storage: myStorage })
19
- * ```
20
- */
21
- async function createSDK(opts = {}) {
22
- const { InstagramSDK } = await import("./sdk.mjs");
23
- const log = opts.log ?? noopLogger;
24
- const storage = opts.storage ?? createStorage();
25
- let http;
26
- let csrfToken = "";
27
- if (opts.http) http = opts.http;
28
- else if (opts.cookies) {
29
- csrfToken = extractCsrfFromCookies(opts.cookies);
30
- http = createHttpClient(void 0, opts.cookies, log);
31
- } else throw new Error("Either \"cookies\" or \"http\" must be provided. Get cookies from browser DevTools → Application → Cookies → instagram.com");
32
- return new InstagramSDK({
33
- http,
34
- storage,
35
- log,
36
- csrfToken
37
- });
38
- }
39
- //#endregion
40
- export { ConfigManager, DownloadJob, Extractor, InstagramAvatarExtractor, InstagramExtractor, InstagramHighlightsExtractor, InstagramInfoExtractor, InstagramPostExtractor, InstagramPostsExtractor, InstagramReelsExtractor, InstagramRestAPI, InstagramSDK, InstagramSavedExtractor, InstagramStoriesExtractor, InstagramTagExtractor, InstagramTaggedExtractor, InstagramUserExtractor, Job, PrintJob, createSDK, directory, ensureHttpScheme, extr, extract, extractAudio, extractTaggedUsers, findTags, idFromShortcode, nameExtFromURL, noopLogger, parseInt, parsePostGraphql, parsePostRest, parseUnicodeEscapes, queue, shortcodeFromId, unescape, unquote, url };
1
+ import { A as directory, C as nameExtFromURL, D as unquote, E as unescape, F as PrintJob, I as Extractor, L as noopLogger, M as url, N as DownloadJob, O as idFromShortcode, P as Job, R as ConfigManager, S as findTags, T as parseUnicodeEscapes, _ as parsePostRest, a as InstagramPostExtractor, b as extr, c as InstagramSavedExtractor, d as InstagramTaggedExtractor, f as InstagramUserExtractor, g as parsePostGraphql, h as extractTaggedUsers, i as InstagramInfoExtractor, j as queue, k as shortcodeFromId, l as InstagramStoriesExtractor, m as extractAudio, n as InstagramAvatarExtractor, o as InstagramPostsExtractor, p as InstagramExtractor, r as InstagramHighlightsExtractor, s as InstagramReelsExtractor, t as InstagramSDK, u as InstagramTagExtractor, v as InstagramRestAPI, w as parseInt, x as extract, y as ensureHttpScheme } from "./sdk-Bn0VCUIT.mjs";
2
+ export { ConfigManager, DownloadJob, Extractor, InstagramAvatarExtractor, InstagramExtractor, InstagramHighlightsExtractor, InstagramInfoExtractor, InstagramPostExtractor, InstagramPostsExtractor, InstagramReelsExtractor, InstagramRestAPI, InstagramSDK, InstagramSavedExtractor, InstagramStoriesExtractor, InstagramTagExtractor, InstagramTaggedExtractor, InstagramUserExtractor, Job, PrintJob, directory, ensureHttpScheme, extr, extract, extractAudio, extractTaggedUsers, findTags, idFromShortcode, nameExtFromURL, noopLogger, parseInt, parsePostGraphql, parsePostRest, parseUnicodeEscapes, queue, shortcodeFromId, unescape, unquote, url };
package/dist/node.cjs ADDED
@@ -0,0 +1,43 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk = require("./sdk-nzhAxf1O.cjs");
3
+ //#region src/node-factory.ts
4
+ /**
5
+ * Create an SDK instance with Node.js defaults.
6
+ *
7
+ * When ``cookies`` is provided, auto-creates an axios-based HttpClient
8
+ * with CSRF token extraction. Pass ``http`` directly for custom adapters.
9
+ *
10
+ * ```ts
11
+ * import { createSDK } from '@chilfish/gallery-dl-instagram/node'
12
+ *
13
+ * // Node.js with cookies
14
+ * const ig = await createSDK({ cookies: 'ds_user_id=...; sessionid=...' })
15
+ *
16
+ * // Custom http adapter (browser / Deno / Edge)
17
+ * const ig = await createSDK({ http: myHttpClient, storage: myStorage })
18
+ * ```
19
+ */
20
+ async function createSDK(opts = {}) {
21
+ const log = opts.log ?? require_sdk.noopLogger;
22
+ let http;
23
+ let storage = opts.storage;
24
+ let csrfToken = "";
25
+ if (opts.http) http = opts.http;
26
+ else if (opts.cookies) {
27
+ const { createHttpClient, extractCsrfFromCookies } = await Promise.resolve().then(() => require("./adapter-CFsiiEpM.cjs"));
28
+ csrfToken = extractCsrfFromCookies(opts.cookies);
29
+ http = createHttpClient(void 0, opts.cookies, log);
30
+ if (!storage) {
31
+ const { createStorage } = await Promise.resolve().then(() => require("./storage-BwGaT6XO.cjs"));
32
+ storage = createStorage();
33
+ }
34
+ } else throw new Error("Either \"cookies\" or \"http\" must be provided. Get cookies from browser DevTools → Application → Cookies → instagram.com");
35
+ return new require_sdk.InstagramSDK({
36
+ http,
37
+ storage,
38
+ log,
39
+ csrfToken
40
+ });
41
+ }
42
+ //#endregion
43
+ exports.createSDK = createSDK;
@@ -0,0 +1,47 @@
1
+ import { b as Storage, n as InstagramSDK, o as Logger, p as HttpClient } from "./sdk-CK9x5wFL.cjs";
2
+
3
+ //#region src/node-factory.d.ts
4
+ /** Options for the Node.js convenience factory. */
5
+ interface CreateSDKOptions {
6
+ /**
7
+ * Full browser Cookie header string.
8
+ * Copy from DevTools → Network → Request Headers → Cookie.
9
+ * Auto-extracts csrftoken for X-CSRFToken header.
10
+ *
11
+ * Either ``cookies`` or ``http`` must be provided.
12
+ */
13
+ cookies?: string;
14
+ /**
15
+ * Custom HttpClient implementation.
16
+ * If omitted, a Node.js axios-based client is created from ``cookies``.
17
+ */
18
+ http?: HttpClient;
19
+ /**
20
+ * Custom Storage implementation for file output.
21
+ * Defaults to Node.js fs/promises-based storage.
22
+ */
23
+ storage?: Storage;
24
+ /**
25
+ * Logger instance. Defaults to a silent no-op logger.
26
+ */
27
+ log?: Logger;
28
+ }
29
+ /**
30
+ * Create an SDK instance with Node.js defaults.
31
+ *
32
+ * When ``cookies`` is provided, auto-creates an axios-based HttpClient
33
+ * with CSRF token extraction. Pass ``http`` directly for custom adapters.
34
+ *
35
+ * ```ts
36
+ * import { createSDK } from '@chilfish/gallery-dl-instagram/node'
37
+ *
38
+ * // Node.js with cookies
39
+ * const ig = await createSDK({ cookies: 'ds_user_id=...; sessionid=...' })
40
+ *
41
+ * // Custom http adapter (browser / Deno / Edge)
42
+ * const ig = await createSDK({ http: myHttpClient, storage: myStorage })
43
+ * ```
44
+ */
45
+ declare function createSDK(opts?: CreateSDKOptions): Promise<InstagramSDK>;
46
+ //#endregion
47
+ export { type CreateSDKOptions, createSDK };