MakerWorld answers an expired or missing auth token with {"error": "Please log
in to download models."} and no download link, which was skipped without a
word, so imports and "Download files from source" just ended with no files.
Now the reason comes back: missing settings, a refused token (probably expired),
no printable files on the page, or a failed download. The import screen shows
it, and the Settings hint explains where the token comes from.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
27 lines
1.5 KiB
JavaScript
27 lines
1.5 KiB
JavaScript
// MakerWorld importer helpers (lib/importers/makerworld.js).
|
||
const test = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const makerworld = require('../lib/importers/makerworld');
|
||
|
||
const page = (design) =>
|
||
`<html><script id="__NEXT_DATA__" type="application/json">${JSON.stringify({ props: { pageProps: { design } } })}</script></html>`;
|
||
|
||
test('printable instances and the license are read from the page data', () => {
|
||
const html = page({
|
||
license: 'Standard Digital File License',
|
||
instances: [{ id: 650088, title: 'AMS - 0.4 Nozzle - 0.08 Layer' }, { id: 650089 }],
|
||
});
|
||
assert.deepEqual(makerworld.parseInstances(html), [
|
||
{ id: 650088, title: 'AMS - 0.4 Nozzle - 0.08 Layer' },
|
||
{ id: 650089, title: '' },
|
||
]);
|
||
assert.equal(makerworld.parseLicense(html), 'Standard Digital File License');
|
||
assert.deepEqual(makerworld.parseInstances('<html><title>Just a moment...</title></html>'), []);
|
||
});
|
||
|
||
test('a download answer without a link says why', () => {
|
||
assert.equal(makerworld.downloadProblem({ name: 'bookmarks.3mf', url: 'https://cdn.example/bookmarks.3mf' }), null);
|
||
assert.match(makerworld.downloadProblem({ code: 1, error: 'Please log in to download models.' }), /token \(it has probably expired\)/);
|
||
assert.equal(makerworld.downloadProblem({ code: 7, error: 'Model not found' }), 'MakerWorld didn’t give a download link: Model not found');
|
||
assert.equal(makerworld.downloadProblem(null), 'MakerWorld didn’t give a download link');
|
||
});
|