Compare commits

..

No commits in common. "bf8e95da974ed78a5c1966281a2bf31b0d9a14d1" and "11fe5c25aa679c177f4ea4a5bb40c790e5c74b19" have entirely different histories.

4 changed files with 19 additions and 17 deletions

View file

@ -23,7 +23,7 @@ A self-hosted web app for organizing your 3D-printing files (STL, 3MF, OBJ, FBX,
- **Notes** — free-form notes per model, saved as you type. - **Notes** — free-form notes per model, saved as you type.
- **Search, filters & sorting** — search across names, descriptions, notes, tags, file names and designers; filter by format, source and license; include *or exclude* tags (match any/all); sort and group by source or format. Press <kbd>/</kbd> to search. - **Search, filters & sorting** — search across names, descriptions, notes, tags, file names and designers; filter by format, source and license; include *or exclude* tags (match any/all); sort and group by source or format. Press <kbd>/</kbd> to search.
- **Duplicate finder** — every file gets a SHA-256 content hash plus (for STL/OBJ/3MF) a geometry fingerprint, computed in the background. Models sharing files are grouped as *exact copies* or *same shape* (renamed, re-exported, converted — or mirrored, so check those), with a recommended copy to keep. Keeping one merges the others' tags, collections and notes into it and moves them to the trash; groups can be dismissed as "not duplicates". - **Duplicate finder** — every file gets a SHA-256 content hash plus (for STL/OBJ/3MF) a geometry fingerprint, computed in the background. Models sharing files are grouped as *exact copies* or *same shape* (renamed, re-exported, converted — or mirrored, so check those), with a recommended copy to keep. Keeping one merges the others' tags, collections and notes into it and moves them to the trash; groups can be dismissed as "not duplicates".
- **Watch a MakerWorld collection** — paste a collection link (private ones work, using your MakerWorld token) and Printhive checks it on a schedule you choose, importing models added to it into a collection of the same name here, optionally AI-tagging the new ones. Each check reads the whole collection (paging through MakerWorld's own load-more call, up to ~640 models) and imports up to 15 of the new ones, spaced out, returning shortly after if more are waiting; models you remove on MakerWorld stay in your library. Each watch shows when it last ran, what it imported, and why a check failed — with a one-click token update when MakerWorld refuses your token. MakerWorld only lets an account download a couple of files in a row before its anti-bot limit refuses the rest, so most models in a big batch arrive as metadata: those are listed as still without files, with a "Get files" button to fetch them a few at a time. - **Watch a MakerWorld collection** — paste a collection link (private ones work, using your MakerWorld token) and Printhive checks it on a schedule you choose, importing models added to it into a collection of the same name here, optionally AI-tagging the new ones. Each check reads the whole collection (paging through MakerWorld's own load-more call, up to ~640 models) and imports up to 15 of the new ones, spaced out, returning shortly after if more are waiting; models you remove on MakerWorld stay in your library. Each watch shows when it last ran, what it imported, and why a check failed — with a one-click token update when MakerWorld refuses your token. A model whose files MakerWorld's anti-bot check blocked is listed as still without files, with a "Get files" button to fetch them later.
- **AI tags & descriptions** — bring your own key for DeepSeek (the default), OpenRouter, OpenAI or any OpenAI-compatible server (Ollama, LM Studio). Tag the whole library, only models not yet tagged, or a single model from its page. Each model's name, file names and (optionally) thumbnail are sent; tags are only ever added and descriptions only filled where empty unless you ask. Optionally it also gives models with unclear names (file-name leftovers, typos, site boilerplate) a clearer one; the old name is kept and can be restored with Undo on the model page. It can also suggest collections (reusing yours where they fit): suggestions wait on the AI page, grouped by name, until you create/add or dismiss them. Each run can do any mix of tags & descriptions, names and collections, and a reply that isn't the JSON asked for is retried once. Runs show live progress, tokens and cost, can be stopped and resumed, stop at an optional spending limit, and pause (rather than keep spending) if the server restarts. "Save & test connection" in Settings checks the key, model and whether it accepts images. - **AI tags & descriptions** — bring your own key for DeepSeek (the default), OpenRouter, OpenAI or any OpenAI-compatible server (Ollama, LM Studio). Tag the whole library, only models not yet tagged, or a single model from its page. Each model's name, file names and (optionally) thumbnail are sent; tags are only ever added and descriptions only filled where empty unless you ask. Optionally it also gives models with unclear names (file-name leftovers, typos, site boilerplate) a clearer one; the old name is kept and can be restored with Undo on the model page. It can also suggest collections (reusing yours where they fit): suggestions wait on the AI page, grouped by name, until you create/add or dismiss them. Each run can do any mix of tags & descriptions, names and collections, and a reply that isn't the JSON asked for is retried once. Runs show live progress, tokens and cost, can be stopped and resumed, stop at an optional spending limit, and pause (rather than keep spending) if the server restarts. "Save & test connection" in Settings checks the key, model and whether it accepts images.
- **Search by meaning** — switch the search box to *Meaning* to find models by what they are ("wall hook" finds a "coat hanger bracket"). Uses a small embedding model (bge-small-en-v1.5, ~34 MB) that runs on the server, so it's free and private; the index updates in the background as models change. - **Search by meaning** — switch the search box to *Meaning* to find models by what they are ("wall hook" finds a "coat hanger bracket"). Uses a small embedding model (bge-small-en-v1.5, ~34 MB) that runs on the server, so it's free and private; the index updates in the background as models change.
- **Automatic tags** — strict whole-word rules over names, file names and archive contents (part types, mechanisms, materials, techniques) plus your own "word → tag" rules. Switch it off (optionally removing its tags) or re-apply it any time. Tags you add yourself are never changed; AI and rule tags are marked on the model page. - **Automatic tags** — strict whole-word rules over names, file names and archive contents (part types, mechanisms, materials, techniques) plus your own "word → tag" rules. Switch it off (optionally removing its tags) or re-apply it any time. Tags you add yourself are never changed; AI and rule tags are marked on the model page.

View file

@ -30,9 +30,6 @@ function start() {
// A check that was running when the server stopped isn't running now. // A check that was running when the server stopped isn't running now.
db.query(`UPDATE watched_collections SET last_status = NULL WHERE last_status = 'checking'`) db.query(`UPDATE watched_collections SET last_status = NULL WHERE last_status = 'checking'`)
.catch((err) => console.warn('Could not clear stale watch checks:', err.message)); .catch((err) => console.warn('Could not clear stale watch checks:', err.message));
// Imports recorded before 'partial' existed: a model with an error kept none of its files.
db.query(`UPDATE watched_collection_items SET status = 'partial' WHERE status = 'imported' AND error IS NOT NULL`)
.catch((err) => console.warn('Could not mark file-less imports:', err.message));
clearInterval(timer); clearInterval(timer);
timer = setInterval(() => { runDue().catch((err) => console.error('Collection watch failed:', err.message)); }, TICK_MS); timer = setInterval(() => { runDue().catch((err) => console.error('Collection watch failed:', err.message)); }, TICK_MS);
if (timer.unref) timer.unref(); if (timer.unref) timer.unref();
@ -157,9 +154,6 @@ async function importFound(watch, collection) {
let problem = null; let problem = null;
const fresh = []; const fresh = [];
for (const design of todo) { for (const design of todo) {
// Paused while this batch was running: stop, rather than import the rest.
const { rows: [live] } = await db.query('SELECT enabled FROM watched_collections WHERE id = $1', [watch.id]);
if (!live || !live.enabled) break;
const url = makerworld.designUrl(design); const url = makerworld.designUrl(design);
try { try {
const result = await deps.importFromUrl(url, { projects: watch.project_id ? [watch.project_id] : [] }); const result = await deps.importFromUrl(url, { projects: watch.project_id ? [watch.project_id] : [] });

View file

@ -5,6 +5,8 @@
const flaresolverr = require('../flaresolverr'); const flaresolverr = require('../flaresolverr');
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
// A model page embeds its printable "instances" in __NEXT_DATA__. Each instance // A model page embeds its printable "instances" in __NEXT_DATA__. Each instance
// id is what the download API takes. // id is what the download API takes.
function parseInstances(html) { function parseInstances(html) {
@ -27,10 +29,9 @@ function parseInstances(html) {
return result; return result;
} }
// MakerWorld answers with an anti-bot message once an account has asked for a // Cloudflare sometimes answers a download call with its anti-bot check instead of
// couple of files in a row. It isn't Cloudflare — FlareSolverr reports no // the JSON — especially during a run of downloads. It comes back as a normal
// challenge, and an unauthenticated call still gets a normal reply — so retrying // answer, so nothing below retries it on its own.
// doesn't clear it; only asking for fewer files does.
const CHALLENGE_RE = /not a robot|just a moment|captcha|attention required|cf[- ]challenge/i; const CHALLENGE_RE = /not a robot|just a moment|captcha|attention required|cf[- ]challenge/i;
function isChallenge(answer) { function isChallenge(answer) {
if (!answer || answer.url) return false; if (!answer || answer.url) return false;
@ -38,11 +39,18 @@ function isChallenge(answer) {
} }
// Resolve an instance to { name, url } (a signed, short-lived CDN download URL). // Resolve an instance to { name, url } (a signed, short-lived CDN download URL).
async function resolveDownload(flaresolverrUrl, instanceId, token) { // A challenge usually clears if we let FlareSolverr's browser try again after a
// pause, so give it a couple of goes before reporting a problem.
async function resolveDownload(flaresolverrUrl, instanceId, token, { retries = 2, waitMs = 8000 } = {}) {
const api = `https://makerworld.com/api/v1/design-service/instance/${instanceId}/f3mf?type=download&fileType=&devModelName=N1`; const api = `https://makerworld.com/api/v1/design-service/instance/${instanceId}/f3mf?type=download&fileType=&devModelName=N1`;
return flaresolverr.solveJson(flaresolverrUrl, api, { const opts = { cookies: [{ name: 'token', value: token, domain: '.makerworld.com' }] };
cookies: [{ name: 'token', value: token, domain: '.makerworld.com' }], let answer;
}); for (let attempt = 0; attempt <= retries; attempt++) {
if (attempt > 0) await sleep(waitMs * attempt);
answer = await flaresolverr.solveJson(flaresolverrUrl, api, opts);
if (!isChallenge(answer)) return answer;
}
return answer;
} }
// Why a download-link answer came back without a link: { message, tokenRejected }, // Why a download-link answer came back without a link: { message, tokenRejected },
@ -55,7 +63,7 @@ function downloadProblem(answer) {
} }
if (isChallenge(answer)) { if (isChallenge(answer)) {
return { return {
message: 'MakerWorld’s anti-bot limit blocked the download — it only allows a couple in a row.', message: 'MakerWorld’s anti-bot check blocked the download. Trying again in a few minutes usually works.',
tokenRejected: false, tokenRejected: false,
challenged: true, challenged: true,
}; };

View file

@ -2200,7 +2200,7 @@ function watchHtml(w) {
${recent.length ? `<div class="watch-recent">${recent.map((i) => ` ${recent.length ? `<div class="watch-recent">${recent.map((i) => `
<span>${i.model_id <span>${i.model_id
? `<button type="button" class="link-btn" data-open-model="${i.model_id}">${escapeHtml(i.model_name || i.title || `Model ${i.model_id}`)}</button>` ? `<button type="button" class="link-btn" data-open-model="${i.model_id}">${escapeHtml(i.model_name || i.title || `Model ${i.model_id}`)}</button>`
: escapeHtml(i.title || i.design_id)}${i.error ? ` <span class="ai-run-error">${escapeHtml(i.error)}</span>` : ''}${i.error && i.model_id : escapeHtml(i.title || i.design_id)}${i.error ? ` <span class="ai-run-error">${escapeHtml(i.error)}</span>` : ''}${i.status === 'partial' && i.model_id
? ` <button type="button" class="link-btn" data-watch="files" data-model-id="${i.model_id}">Get files</button>` : ''}</span>`).join('')}</div>` : ''} ? ` <button type="button" class="link-btn" data-watch="files" data-model-id="${i.model_id}">Get files</button>` : ''}</span>`).join('')}</div>` : ''}
</div>`; </div>`;
} }