@viralspin/mcp 0.5.2 → 0.5.3
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/tools/organize.js +21 -11
- package/package.json +1 -1
package/dist/tools/organize.js
CHANGED
|
@@ -127,6 +127,7 @@ exports.organizeAddToStoryTool = {
|
|
|
127
127
|
return addPlanToStory(file, { post: client_js_1.post });
|
|
128
128
|
},
|
|
129
129
|
};
|
|
130
|
+
const UPLOADS_AT_ONCE = 16;
|
|
130
131
|
/** Upload a plan's tags + 480px thumbnails to My Story (the opt-in). Used by the tool and by the connector when the web app asks. */
|
|
131
132
|
/** `only`: bucket keys ("image:Family", "video:Outfits") when the creator picked some folders; all of them when absent. */
|
|
132
133
|
const bucketKey = (b) => `${b.media ?? "any"}:${b.name}`;
|
|
@@ -154,17 +155,26 @@ async function addPlanToStory(file, io, progress, only) {
|
|
|
154
155
|
});
|
|
155
156
|
added += r.added;
|
|
156
157
|
const byRel = new Map(chunk.map((c) => [c.item.rel, c.item]));
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
158
|
+
// UPLOADS_AT_ONCE thumbnails in flight: one at a time left the line idle (12,700 pictures were "about 38 minutes")
|
|
159
|
+
let next = 0;
|
|
160
|
+
const worker = async () => {
|
|
161
|
+
while (next < r.uploads.length) {
|
|
162
|
+
const u = r.uploads[next++];
|
|
163
|
+
const t = byRel.get(u.rel)?.thumb;
|
|
164
|
+
if (!t)
|
|
165
|
+
continue;
|
|
166
|
+
try {
|
|
167
|
+
const form = new FormData();
|
|
168
|
+
form.append("cacheControl", "31536000");
|
|
169
|
+
form.append("", new Blob([await fs_1.default.promises.readFile(t)], { type: "image/jpeg" }), "t.jpg");
|
|
170
|
+
const resp = await fetch(u.upload_url, { method: "PUT", body: form, headers: { "x-upsert": "true" } });
|
|
171
|
+
if (resp.ok)
|
|
172
|
+
thumbs++;
|
|
173
|
+
}
|
|
174
|
+
catch { /* one thumbnail missing never stops the rest */ }
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
await Promise.all(Array.from({ length: Math.min(UPLOADS_AT_ONCE, r.uploads.length) }, worker));
|
|
168
178
|
progress?.(Math.min(k + 200, totalN), totalN);
|
|
169
179
|
}
|
|
170
180
|
return `Added ${added} file(s) from "${label}" to My Story in ${plan.buckets.filter((b) => b.kind !== "duplicates").length} bucket(s) (${thumbs} thumbnail(s) uploaded; originals stay on this computer). They show in My Story ▸ Organized and feed carousels and 7s reels. organize_add_to_story {plan:"${plan.id}", remove:true} takes them back out.`;
|
package/package.json
CHANGED