/**
 * 光湖视频AI · 秦山号 · 批量生成镜2-镜7
 * D131 · 铸渊 ICE-GL-ZY001
 */
const path = require('path');
const { generateVideo } = require('../engines/video-api-adapter');

const SHOTS = [
  { id: 'shot02', prompt: '33岁亚洲男性双手特写，粗糙老茧，黑色机油嵌入指甲缝，昏暗灯光下一双劳动者的手，真人科幻短剧，写实质感，低饱和度冷色调', duration: '5' },
  { id: 'shot03', prompt: '船舱剧烈震动，33岁亚洲男人身着深蓝工装从床铺猛地坐起抓住床头铁杆，特写铁杆上金属铭牌标记秦山号，紧张氛围，真人科幻写实风格', duration: '5' },
  { id: 'shot04', prompt: '布满灰尘的圆形舷窗观察窗，一道非人黑影极速掠过，33岁男人猛转头警觉，惊悚氛围，真人科幻写实风格，低饱和度冷色调', duration: '5' },
  { id: 'shot05', prompt: '破旧工具包打开特写，金属工牌：编号000768姓名林昊岗位模糊不清，照片上人脸部位被利器划烂，隐约可见年轻帅气轮廓，暗光悬疑，真人科幻写实风格', duration: '5' },
  { id: 'shot06', prompt: '33岁亚洲男人身着深蓝工装背起硕大黑色工具包，手持半米长金属管钳，走向锈蚀舱门，逆光剪影侧身轮廓，决然姿态，真人科幻写实风格，电影级光影', duration: '5' },
  { id: 'shot07', prompt: '管钳砸向舱门下液压凸起装置，白色蒸汽猛烈喷射，33岁男人咬紧牙关用力，门把手缓缓转动，紧张氛围，真人科幻写实风格', duration: '5' },
];

async function runShot(shot) {
  const outputPath = path.resolve(__dirname, `../outputs/shots/qinshan-ep01-${shot.id}.mp4`);
  console.log(`\n🎬 ${shot.id} · ${shot.prompt.substring(0, 40)}...`);
  try {
    const result = await generateVideo({ ...shot, resolution: '1080p', outputPath });
    console.log(`  ✅ ${shot.id} 完成 · ${result.taskId}`);
    return { ok: true, ...result };
  } catch (err) {
    console.error(`  ❌ ${shot.id} 失败: ${err.message}`);
    return { ok: false, error: err.message };
  }
}

async function main() {
  console.log('='.repeat(60));
  console.log('🎬 秦山号 · 批量生成镜2-镜7');
  console.log('   共6镜 · 每镜5秒 · Seedance 2.0 真人写实');
  console.log('='.repeat(60));

  const results = [];
  for (const shot of SHOTS) {
    results.push(await runShot(shot));
  }

  console.log('\n' + '='.repeat(60));
  const ok = results.filter(r => r.ok).length;
  const fail = results.filter(r => !r.ok).length;
  console.log(`✅ ${ok}成功 ❌ ${fail}失败 / 共${SHOTS.length}`);
  if (fail > 0) {
    results.filter(r => !r.ok).forEach(r => console.log(`  ❌ ${r.error}`));
  }
  console.log('='.repeat(60));
}
main();
