83 lines
3.1 KiB
Python
Executable File
83 lines
3.1 KiB
Python
Executable File
from __future__ import annotations
|
|
|
|
import json
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
from docx import Document
|
|
from docx.oxml.ns import qn
|
|
|
|
|
|
path = Path(r"D:\workspace\digital_me\artifacts\《我为你研墨》音频对齐脚本与分镜提示词.docx")
|
|
issues = []
|
|
with zipfile.ZipFile(path) as zf:
|
|
bad_member = zf.testzip()
|
|
if bad_member:
|
|
issues.append(f"Corrupt ZIP member: {bad_member}")
|
|
|
|
doc = Document(path)
|
|
all_text = "\n".join(p.text for p in doc.paragraphs)
|
|
for table in doc.tables:
|
|
for row in table.rows:
|
|
all_text += "\n" + "\t".join(cell.text for cell in row.cells)
|
|
|
|
for marker in ("TODO", "TBD", "【统一风格前缀】", "placeholder"):
|
|
if marker in all_text:
|
|
issues.append(f"Unexpected placeholder marker: {marker}")
|
|
|
|
scene_headings = [p.text for p in doc.paragraphs if p.style.name == "Heading 1" and p.text.startswith("镜 ")]
|
|
if len(scene_headings) != 15:
|
|
issues.append(f"Expected 15 scene headings, found {len(scene_headings)}")
|
|
|
|
if all_text.count("10秒图生视频提示词(可直接复制)") != 15:
|
|
issues.append("10-second prompt section count is not 15")
|
|
if all_text.count("生成时长严格10秒") != 15:
|
|
issues.append("Not every prompt is explicitly fixed to 10 seconds")
|
|
if all_text.count("统一负面提示|") != 15:
|
|
issues.append("Per-scene negative prompt count is not 15")
|
|
if "03:19.15" not in all_text or "199.152" not in all_text:
|
|
issues.append("Verified audio duration is missing")
|
|
|
|
table_geometry = []
|
|
for index, table in enumerate(doc.tables, start=1):
|
|
tblpr = table._tbl.tblPr
|
|
tblw = tblpr.find(qn("w:tblW"))
|
|
tblind = tblpr.find(qn("w:tblInd"))
|
|
grid_widths = [int(n.get(qn("w:w"))) for n in table._tbl.tblGrid.findall(qn("w:gridCol"))]
|
|
row_widths = []
|
|
for row in table.rows:
|
|
widths = []
|
|
for cell in row.cells:
|
|
tcw = cell._tc.get_or_add_tcPr().find(qn("w:tcW"))
|
|
widths.append(int(tcw.get(qn("w:w"))) if tcw is not None else None)
|
|
row_widths.append(widths)
|
|
expected = sum(grid_widths)
|
|
if tblw is None or int(tblw.get(qn("w:w"))) != expected:
|
|
issues.append(f"Table {index}: tblW/grid mismatch")
|
|
if expected != 9360:
|
|
issues.append(f"Table {index}: expected 9360 DXA, got {expected}")
|
|
if any(widths != grid_widths for widths in row_widths):
|
|
issues.append(f"Table {index}: tcW/grid mismatch")
|
|
table_geometry.append({
|
|
"table": index,
|
|
"rows": len(table.rows),
|
|
"cols": len(table.columns),
|
|
"width_dxa": expected,
|
|
"indent_dxa": int(tblind.get(qn("w:w"))) if tblind is not None else None,
|
|
})
|
|
|
|
result = {
|
|
"file": str(path),
|
|
"bytes": path.stat().st_size,
|
|
"paragraphs": len(doc.paragraphs),
|
|
"tables": len(doc.tables),
|
|
"scene_headings": len(scene_headings),
|
|
"prompt_sections": all_text.count("10秒图生视频提示词(可直接复制)"),
|
|
"fixed_10s_prompts": all_text.count("生成时长严格10秒"),
|
|
"table_geometry": table_geometry,
|
|
"issues": issues,
|
|
"status": "PASS" if not issues else "FAIL",
|
|
}
|
|
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
raise SystemExit(0 if not issues else 1)
|