@chilfish/gallery-dl-instagram 0.1.0 → 0.2.2

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.cjs ADDED
@@ -0,0 +1,192 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk = require("./sdk-BClg0Kv2.cjs");
3
+ //#region src/core/print-job.ts
4
+ var PrintJob = class PrintJob extends require_sdk.Job {
5
+ _currentDir = {};
6
+ _files = [];
7
+ _postCount = 0;
8
+ _fileCount = 0;
9
+ _width;
10
+ constructor(extractor) {
11
+ super(extractor);
12
+ this._width = Math.min(process.stdout.columns ?? 80, 100);
13
+ }
14
+ async handleDirectory(msg) {
15
+ if (this._postCount > 0) this._flushPost();
16
+ this._currentDir = { ...msg.metadata };
17
+ this._postCount++;
18
+ this._files = [];
19
+ }
20
+ async handleUrl(msg) {
21
+ const meta = {
22
+ ...this._currentDir,
23
+ ...msg.metadata
24
+ };
25
+ this._fileCount++;
26
+ const ext = meta.extension ?? "jpg";
27
+ const mid = meta.media_id ?? "?";
28
+ this._files.push({
29
+ num: meta.num ?? this._files.length + 1,
30
+ filename: `${mid}.${ext}`,
31
+ width: meta.width ?? 0,
32
+ height: meta.height ?? 0,
33
+ videoUrl: meta.video_url ?? null,
34
+ audioUrl: meta.audio_url ?? null
35
+ });
36
+ }
37
+ async handleQueue(msg) {
38
+ if (this._files.length > 0 || this._postCount > 0) this._flushPost();
39
+ this._postCount = 0;
40
+ this._files = [];
41
+ const extrClass = {
42
+ ...this._currentDir,
43
+ ...msg.metadata
44
+ }._extractor;
45
+ if (!extrClass || typeof extrClass !== "object") return;
46
+ const cls = extrClass;
47
+ const match = cls.pattern.exec(msg.url);
48
+ if (!match) return;
49
+ const parentExtr = this.extractor;
50
+ const childJob = new PrintJob(Reflect.construct(cls, [{
51
+ url: msg.url,
52
+ match,
53
+ config: parentExtr.config,
54
+ http: parentExtr.http,
55
+ storage: parentExtr.storage,
56
+ log: parentExtr.log
57
+ }]));
58
+ const childStatus = await childJob.run();
59
+ this.status |= childStatus;
60
+ this._postCount += childJob._postCount;
61
+ this._fileCount += childJob._fileCount;
62
+ }
63
+ _flushPost() {
64
+ const m = this._currentDir;
65
+ if (Object.keys(m).length === 0) return;
66
+ const w = this._width;
67
+ const labelW = 14;
68
+ const shortcode = m.post_shortcode ?? "?";
69
+ const header = ` Post #${this._postCount}: ${shortcode} `;
70
+ const padTotal = w - 2 - header.length;
71
+ const padL = Math.floor(padTotal / 2);
72
+ const padR = padTotal - padL;
73
+ process.stdout.write(`\n${require_sdk.dim("┌")}${"─".repeat(padL)}${require_sdk.b(header)}${"─".repeat(padR)}${require_sdk.dim("┐")}\n`);
74
+ const row = (label, value, color) => {
75
+ const colored = typeof color === "function" ? color(value) : color ? `${color}${value}${require_sdk._RESET}` : value;
76
+ process.stdout.write(` ${require_sdk.dim("│")} ${require_sdk.c(require_sdk.pad(label, labelW))} ${colored}\n`);
77
+ };
78
+ const username = m.username ?? "?";
79
+ const fullname = m.fullname ?? "";
80
+ row("Author:", fullname ? `${username} (${fullname})` : username, require_sdk.g);
81
+ row("Date:", m.date ?? m.post_date ?? "?");
82
+ row("Likes:", `${typeof m.likes === "number" ? m.likes.toLocaleString() : "?"} | Liked: ${m.liked ? "yes" : "no"}`);
83
+ row("Type:", `${m.type ?? "?"} (${this._files.length} files)`);
84
+ row("URL:", m.post_url ?? "?");
85
+ const desc = m.description ?? "";
86
+ if (desc) {
87
+ process.stdout.write(` ${require_sdk.dim("│")}\n`);
88
+ process.stdout.write(` ${require_sdk.dim("│")} ${require_sdk.b("Description:")}\n`);
89
+ for (const line of desc.split("\n")) for (const wl of this._wrap(line, w - 8)) process.stdout.write(` ${require_sdk.dim("│")} ${require_sdk.dim(wl)}\n`);
90
+ }
91
+ const tags = m.tags;
92
+ if (tags && tags.length > 0) {
93
+ process.stdout.write(` ${require_sdk.dim("│")}\n`);
94
+ process.stdout.write(` ${require_sdk.dim("│")} ${require_sdk.b("Tags:")} ${require_sdk.dim(tags.map((t) => `#${t}`).join(" "))}\n`);
95
+ }
96
+ const locName = m.location_slug ?? "";
97
+ const locId = m.location_id ?? "";
98
+ if (locName || locId) row("Location:", locId ? `${locName} (ID: ${locId})` : locName);
99
+ const coauthors = m.coauthors;
100
+ if (coauthors && coauthors.length > 0) row("Co-authors:", coauthors.map((c) => c.full_name ? `${c.username} (${c.full_name})` : c.username).join(", "));
101
+ const pinned = m.pinned;
102
+ if (pinned && pinned.length > 0) row("Pinned:", pinned.join(", "));
103
+ const expires = m.expires;
104
+ if (expires) row("Expires:", expires, require_sdk._YELLOW);
105
+ const hlTitle = m.highlight_title;
106
+ if (hlTitle) row("Highlight:", hlTitle);
107
+ const taggedUser = m.tagged_username ?? "";
108
+ if (taggedUser) {
109
+ const taggedFull = m.tagged_full_name ?? "";
110
+ row("Tagged by:", taggedFull ? `${taggedUser} (${taggedFull})` : taggedUser);
111
+ }
112
+ if (this._files.length > 0) {
113
+ process.stdout.write(` ${require_sdk.dim("│")}\n`);
114
+ process.stdout.write(` ${require_sdk.dim("│")} ${require_sdk.b(`Media (${this._files.length} files):`)}\n`);
115
+ const maxNumW = String(this._files.length).length;
116
+ const maxFileW = Math.max(...this._files.map((f) => f.filename.length));
117
+ const dimW = Math.min(maxFileW, 40);
118
+ for (const f of this._files) {
119
+ const numStr = `[${String(f.num).padStart(maxNumW)}]`;
120
+ const dimStr = f.filename.length > 40 ? `${f.filename.slice(0, 37)}...` : require_sdk.pad(f.filename, dimW);
121
+ const res = f.width ? `${f.width}x${f.height}` : "?x?";
122
+ const badges = [];
123
+ if (f.videoUrl) badges.push("video");
124
+ if (f.audioUrl) badges.push("audio");
125
+ let line = ` ${require_sdk.dim("│")} ${require_sdk.g(numStr)} ${dimStr} ${res}`;
126
+ if (badges.length > 0) line += ` ${require_sdk._YELLOW}(${badges.join("+")})${require_sdk._RESET}`;
127
+ process.stdout.write(`${line}\n`);
128
+ }
129
+ }
130
+ process.stdout.write(` ${require_sdk.dim("└")}${"─".repeat(w - 2)}${require_sdk.dim("┘")}\n`);
131
+ }
132
+ _wrap(text, maxLen) {
133
+ if (text.length <= maxLen) return [text];
134
+ const lines = [];
135
+ let remaining = text;
136
+ while (remaining.length > maxLen) {
137
+ let cut = maxLen;
138
+ while (cut > 0 && remaining[cut] !== " ") cut--;
139
+ if (cut === 0) cut = maxLen;
140
+ lines.push(remaining.slice(0, cut).trimEnd());
141
+ remaining = remaining.slice(cut).trimStart();
142
+ }
143
+ if (remaining) lines.push(remaining);
144
+ return lines;
145
+ }
146
+ _report() {
147
+ this._flushPost();
148
+ process.stdout.write(`\n${require_sdk.dim("──")} ${require_sdk.b("Summary")} ${require_sdk.dim("───")}\n`);
149
+ process.stdout.write(` Posts: ${require_sdk.g(String(this._postCount))}\n`);
150
+ process.stdout.write(` Files: ${require_sdk.g(String(this._fileCount))}\n`);
151
+ process.stdout.write(`\n`);
152
+ }
153
+ };
154
+ //#endregion
155
+ exports.ConfigManager = require_sdk.ConfigManager;
156
+ exports.DownloadJob = require_sdk.DownloadJob;
157
+ exports.Extractor = require_sdk.Extractor;
158
+ exports.InstagramAvatarExtractor = require_sdk.InstagramAvatarExtractor;
159
+ exports.InstagramExtractor = require_sdk.InstagramExtractor;
160
+ exports.InstagramHighlightsExtractor = require_sdk.InstagramHighlightsExtractor;
161
+ exports.InstagramInfoExtractor = require_sdk.InstagramInfoExtractor;
162
+ exports.InstagramPostExtractor = require_sdk.InstagramPostExtractor;
163
+ exports.InstagramPostsExtractor = require_sdk.InstagramPostsExtractor;
164
+ exports.InstagramReelsExtractor = require_sdk.InstagramReelsExtractor;
165
+ exports.InstagramRestAPI = require_sdk.InstagramRestAPI;
166
+ exports.InstagramSDK = require_sdk.InstagramSDK;
167
+ exports.InstagramSavedExtractor = require_sdk.InstagramSavedExtractor;
168
+ exports.InstagramStoriesExtractor = require_sdk.InstagramStoriesExtractor;
169
+ exports.InstagramTagExtractor = require_sdk.InstagramTagExtractor;
170
+ exports.InstagramTaggedExtractor = require_sdk.InstagramTaggedExtractor;
171
+ exports.InstagramUserExtractor = require_sdk.InstagramUserExtractor;
172
+ exports.Job = require_sdk.Job;
173
+ exports.PrintJob = PrintJob;
174
+ exports.directory = require_sdk.directory;
175
+ exports.ensureHttpScheme = require_sdk.ensureHttpScheme;
176
+ exports.extr = require_sdk.extr;
177
+ exports.extract = require_sdk.extract;
178
+ exports.extractAudio = require_sdk.extractAudio;
179
+ exports.extractTaggedUsers = require_sdk.extractTaggedUsers;
180
+ exports.findTags = require_sdk.findTags;
181
+ exports.idFromShortcode = require_sdk.idFromShortcode;
182
+ exports.nameExtFromURL = require_sdk.nameExtFromURL;
183
+ exports.noopLogger = require_sdk.noopLogger;
184
+ exports.parseInt = require_sdk.parseInt;
185
+ exports.parsePostGraphql = require_sdk.parsePostGraphql;
186
+ exports.parsePostRest = require_sdk.parsePostRest;
187
+ exports.parseUnicodeEscapes = require_sdk.parseUnicodeEscapes;
188
+ exports.queue = require_sdk.queue;
189
+ exports.shortcodeFromId = require_sdk.shortcodeFromId;
190
+ exports.unescape = require_sdk.unescape;
191
+ exports.unquote = require_sdk.unquote;
192
+ exports.url = require_sdk.url;