feat(supporters): 홈페이지 이미지 단계 — 의료법 기준 이미지 규칙 문서, collect_images.mjs+img_process.py(법 조건부 이미지 자동 제외, 글자 이미지 검사), 워커 images 단계, 글별 히어로·갤러리 매칭. 원진 66장 반영 재배포

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Fable 5.1 committed 2026-09-08 09:34:48 +09:00
1 parent eb873bc43a
commit dc0d233b58
9 files changed
+397 -14

No files matched your search

+33 -4
View File
@@ -26,7 +26,7 @@ const clinic = opt('clinic'); const url = opt('url');
if (!clinic || !url) { console.error('사용법: --clinic <id> --url <https://...>'); process.exit(2); }
const WORK = resolve(opt('work', join(homedir(), 'supporters-builds', clinic)));
const today = new Date().toISOString().slice(0, 10);
const PHASES = ['evidence', 'data', 'youtube', 'inputs', 'briefs', 'generate', 'build', 'deploy', 'done'];
const PHASES = ['evidence', 'data', 'youtube', 'images', 'inputs', 'briefs', 'generate', 'build', 'deploy', 'done'];
const startFrom = opt('from', 'evidence');
(function loadEnv() { const p = join(ROOT, '.env'); if (!existsSync(p)) return; for (const line of readFileSync(p, 'utf8').split('\n')) { const m = line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/); if (m && !process.env[m[1]]) process.env[m[1]] = m[2].replace(/^["']|["']$/g, ''); } })();
@@ -175,6 +175,31 @@ await phase('youtube', () => {
return notes.concat(`${v.channel.title} · 영상 ${v.channel.videos} · 설명형 롱폼 ${v.topLong.length} · 쇼츠 ${v.topShorts.length}`).join(' · ');
});
// 2c. 홈페이지 이미지 (규칙: docs/INFINITH_Supporters_Image_Rules.md). 전후·사례·모델·비교·수상·수술 장면은 자동 제외.
await phase('images', () => {
if (flag('no-images')) return '건너뜀 (--no-images)';
const r = run('node', ['scripts/collect_images.mjs', '--clinic', clinic, '--evidence', EV, '--site', SITE]);
if (!r.ok || !existsSync(join(DATA, 'images.json'))) throw new Error(`이미지 수집 실패\n${tail(r.out)}`);
const m = readJson(join(DATA, 'images.json'));
const by = (c) => m.items.filter((i) => i.category === c);
const site = readJson(join(DATA, 'site.json'));
const clinicImgs = by('clinic');
const wide = clinicImgs.filter((i) => i.width / i.height >= 1.4);
if (wide[0] && !site.heroImage?.src) site.heroImage = { src: wide[0].src, alt: wide[0].alt, width: wide[0].width, height: wide[0].height };
const building = clinicImgs.find((i) => /외관|건물|building|exterior/.test(i.src + i.alt)) ?? clinicImgs[1] ?? clinicImgs[0];
if (building && !site.buildingImage?.src) site.buildingImage = { src: building.src, alt: building.alt, caption: building.caption };
const gal = (list) => list.map((i) => ({ src: i.src, alt: i.alt, caption: i.caption }));
if (!site.insideGallery?.length) site.insideGallery = gal(clinicImgs.slice(0, 6));
if (!site.clinicGallery?.length) site.clinicGallery = gal(clinicImgs.slice(6, 12).length ? clinicImgs.slice(6, 12) : clinicImgs.slice(0, 6));
site.imageCredit = site.imageCredit || `사진 출처: ${readJson(join(DATA, 'factSheet.json')).shortName || '병원'} 공식 홈페이지 (${m.capturedAt} 캡처)`;
writeJson(join(DATA, 'site.json'), site);
const authors = readJson(join(DATA, 'authors.json'));
let docImgs = 0;
for (const i of by('doctors')) if (i.doctorId && authors.physicians?.[i.doctorId] && !authors.physicians[i.doctorId].image) { authors.physicians[i.doctorId].image = i.src; docImgs++; }
writeJson(join(DATA, 'authors.json'), authors);
return `${m.items.length}장 (의료진 ${by('doctors').length}, 시설 ${clinicImgs.length}, 시술 ${by('procedure').length}, 장비 ${by('equipment').length}) · 원장 사진 ${docImgs}명 · 히어로 ${site.heroImage?.src ? '설정' : '없음'}`;
});
// 3. 병원 입력 반영 (있으면)
await phase('inputs', () => {
if (!opt('inputs') && !flag('from-supabase')) return '입력 없음 (확인 대기로 발행)';
@@ -209,9 +234,13 @@ await phase('generate', () => {
const src = readFileSync(p, 'utf8');
const m = src.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/); if (!m) continue;
const data = yaml.load(m[1]) ?? {};
const next = b.videos ?? [];
if (JSON.stringify(data.videos ?? []) === JSON.stringify(next)) continue; // brief 가 영상의 단일 원본. 같으면 건너뛴다
data.videos = next;
// brief 가 영상·히어로·갤러리·썸네일의 단일 원본. 같으면 건너뛴다
const next = { videos: b.videos ?? [], hero: b.hero ?? undefined, gallery: b.gallery ?? [], thumbnail: b.thumbnail ?? undefined };
const cur = { videos: data.videos ?? [], hero: data.hero ?? undefined, gallery: data.gallery ?? [], thumbnail: data.thumbnail ?? undefined };
if (JSON.stringify(cur) === JSON.stringify(next)) continue;
data.videos = next.videos; data.gallery = next.gallery;
if (next.hero) data.hero = next.hero; else delete data.hero;
if (next.thumbnail) data.thumbnail = next.thumbnail; else delete data.thumbnail;
writeFileSync(p, `---\n${yaml.dump(data, { lineWidth: -1, noRefs: true, quotingType: '"' })}---\n${m[2].trim()}\n`);
attached++;
}