@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/LICENSE +340 -0
- package/README.md +134 -0
- package/dist/dl-ins.mjs +5014 -0
- package/dist/index.cjs +192 -0
- package/dist/{sdk-B9fRyc1e.d.mts → index.d.cts} +189 -309
- package/dist/index.d.mts +502 -72
- package/dist/index.mjs +153 -39
- package/dist/node.cjs +41 -0
- package/dist/node.d.cts +47 -0
- package/dist/node.d.mts +47 -0
- package/dist/node.mjs +40 -0
- package/dist/sdk-BClg0Kv2.cjs +2268 -0
- package/dist/{extractors-Byw-2lPL.mjs → sdk-CovBsEps.mjs} +720 -670
- package/dist/sdk-DyZz22bT.d.cts +262 -0
- package/dist/sdk-DyZz22bT.d.mts +262 -0
- package/dist/storage-77hqz5Fi.mjs +24 -0
- package/dist/storage-BwGaT6XO.cjs +24 -0
- package/package.json +26 -26
- package/cli/adapter.ts +0 -284
- package/cli/cookies.ts +0 -59
- package/cli/index.ts +0 -337
- package/config.ts +0 -80
- package/core/extractor.ts +0 -217
- package/core/job.ts +0 -581
- package/dist/adapter-Bt86eL1R.mjs +0 -189
- package/dist/cli/index.d.mts +0 -1
- package/dist/cli/index.mjs +0 -3160
- package/dist/sdk.d.mts +0 -2
- package/dist/sdk.mjs +0 -93
- package/index.ts +0 -159
- package/instagram/api.ts +0 -531
- package/instagram/base.ts +0 -275
- package/instagram/extractors.ts +0 -521
- package/instagram/index.ts +0 -43
- package/instagram/parsers.ts +0 -583
- package/instagram/types.ts +0 -244
- package/message.ts +0 -31
- package/types.ts +0 -115
- package/utils/id-codec.ts +0 -39
- package/utils/text.ts +0 -178
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;
|