fix: MakerWorld 다운로드 profileId 선택 — hits[].id는 인스턴스 id라 iot-service 400
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -325,7 +325,8 @@ async function resolveMakerWorldDownload(id: string, token: string): Promise<Res
|
||||
const modelId = detail.json?.design?.modelId || detail.json?.modelId || detail.json?.data?.modelId;
|
||||
const inst = await jsonFetch(`https://api.bambulab.com/v1/design-service/design/${id}/instances`);
|
||||
const hits = Array.isArray(inst.json?.hits) ? inst.json.hits : (Array.isArray(inst.json?.data?.hits) ? inst.json.data.hits : []);
|
||||
const profileId = hits[0]?.id || hits[0]?.profileId || hits[0]?._id;
|
||||
// 주의: hits[].id는 "인스턴스" id(647181식)라 iot-service에 안 통한다 — profileId(141248202식)가 정답(2026-09-23 실측)
|
||||
const profileId = hits[0]?.profileId || hits[0]?.id || hits[0]?._id;
|
||||
if (!modelId || !profileId) throw new Error(`MakerWorld 모델 ${id}의 파일 인스턴스를 찾지 못했습니다 (API 응답 구조가 변경된 것 같습니다) — 웹에서 직접 받아야 합니다.`);
|
||||
const prof = await jsonFetch(
|
||||
`https://api.bambulab.com/v1/iot-service/api/user/profile/${profileId}?model_id=${encodeURIComponent(String(modelId))}`,
|
||||
@@ -346,7 +347,8 @@ async function resolveMakerWorldDownload(id: string, token: string): Promise<Res
|
||||
};
|
||||
const url = findUrl(prof.json);
|
||||
if (!url) throw new Error(`MakerWorld presigned URL을 응답에서 찾지 못했습니다 — 토큰이 만료됐거나 권한이 없을 수 있습니다. ${downloadErrorDetail('makerworld', prof.status, '')}`);
|
||||
return { url, headers: {}, ext: '.3mf', name: `makerworld_${id}.3mf`, totalFiles: hits.length };
|
||||
const title = String(detail.json?.design?.title || detail.json?.title || '').trim();
|
||||
return { url, headers: {}, ext: '.3mf', name: title || `makerworld_${id}`, totalFiles: hits.length };
|
||||
}
|
||||
|
||||
// ─── 인증 다운로드 (print3d.ts downloadStl의 스니프/캡 로직 재사용 형태) ─────
|
||||
|
||||
Reference in New Issue
Block a user