You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 line
1.9 KiB

  1. import fs from 'node:fs';
  2. import assert from 'node:assert/strict';
  3. import {createHash} from 'node:crypto';
  4. import videos from '../../unreal_tran_web/src/features/virtual-training-scripts/narration-video-manifest.js';
  5. import speech from '../../unreal_tran_web/src/features/virtual-training-scripts/narration-manifest.js';
  6. const origin=process.env.BASE_URL || 'http://127.0.0.1:6180';
  7. const directory=process.env.REPORT_DIR || 'reports/bridge-lecture-polish-20260915/local';
  8. const sha=b=>createHash('sha256').update(b).digest('hex');
  9. const clips=videos.scripts.flatMap(s=>s.steps);
  10. const sounds=speech.scripts.flatMap(s=>s.steps.flatMap(c=>[{url:c.url,sha256:c.stepSha256},...(c.safetyUrl?[{url:c.safetyUrl,sha256:c.safetySha256}]:[])]));
  11. assert.equal(clips.length,39);
  12. for(const pack of speech.scripts)for(const clip of pack.steps)assert.doesNotMatch(clip.text+' '+clip.safetyText,/原稿|原图|没有展开|未展开|没有给出|概括项|本预演|相反描述/);
  13. for(const group of [clips,sounds]) {
  14. for(let start=0;start<group.length;start+=4)await Promise.all(group.slice(start,start+4).map(async clip=>{
  15. const r=await fetch(origin+clip.url,{signal:AbortSignal.timeout(60000)});
  16. assert.equal(r.status,200,clip.url);
  17. assert.equal(sha(Buffer.from(await r.arrayBuffer())),clip.sha256,clip.url);
  18. assert.equal(sha(fs.readFileSync(new URL('../../unreal_tran_web/dist'+clip.url,import.meta.url))),clip.sha256);
  19. }));
  20. }
  21. const range=await fetch(origin+clips[0].url,{headers:{Range:'bytes=0-1023'}});
  22. assert.equal(range.status,206);assert.equal((await range.arrayBuffer()).byteLength,1024);
  23. fs.mkdirSync(directory,{recursive:true});
  24. const result={origin,videos:clips.length,audio:sounds.length,allTextsClean:true,exactFiles:true,buildCopiesMatch:true,rangeRequests:true};
  25. fs.writeFileSync(directory+'/delivery.json',JSON.stringify(result,null,2));console.log(JSON.stringify(result));