Initial commit: lesson-highlights generator
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
f = open(r'D:\F\NewI\opencode\daily-workspace\temp\cli_run_log.txt', 'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
|
||||
print('Total bytes:', len(data))
|
||||
print('First 300 hex:', data[:300].hex())
|
||||
print()
|
||||
print('UTF-8 decode of first 300:')
|
||||
print(data[:300].decode('utf-8', 'replace'))
|
||||
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" -c "import pptx; print('pptx available')"
|
||||
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" "D:\F\NewI\opencode\daily-workspace\projects\piano-highlight-app\temp\check_pptx2.py"
|
||||
@@ -0,0 +1,10 @@
|
||||
import sys
|
||||
out = r"D:\F\NewI\opencode\daily-workspace\temp\check_pptx_out.txt"
|
||||
try:
|
||||
import pptx
|
||||
result = "pptx available: " + pptx.__version__
|
||||
except ImportError as e:
|
||||
result = "pptx NOT available: " + str(e)
|
||||
with open(out, "w", encoding="utf-8") as f:
|
||||
f.write(result)
|
||||
print(result)
|
||||
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" "D:\F\NewI\opencode\daily-workspace\projects\piano-highlight-app\temp\check_transcript.py"
|
||||
@@ -0,0 +1,17 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
inter_dir = r"D:\F\NewI\opencode\daily-workspace\projects\piano-lesson-highlights\cases\lesson1\output_cli_full\intermediates"
|
||||
transcript_file = os.path.join(inter_dir, "full_transcript.json")
|
||||
|
||||
if os.path.exists(transcript_file):
|
||||
size = os.path.getsize(transcript_file)
|
||||
with open(transcript_file, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
print(f"Transcript exists: {size} bytes")
|
||||
print(f"Segments: {len(data)}")
|
||||
if data:
|
||||
print(f"First segment: {data[0]}")
|
||||
print(f"Last segment: {data[-1]}")
|
||||
else:
|
||||
print("Transcript file NOT found")
|
||||
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" "D:\F\NewI\opencode\daily-workspace\projects\piano-highlight-app\temp\debug_ppt.py"
|
||||
pause
|
||||
@@ -0,0 +1,30 @@
|
||||
import zipfile
|
||||
import re
|
||||
|
||||
ppt = r"D:\F\yc\课程上架\福田商圈夜校\课程视频\钢琴演奏入门第一课.pptx"
|
||||
|
||||
with zipfile.ZipFile(ppt, "r") as z:
|
||||
names = z.namelist()
|
||||
slide_files = [f for f in names if f.startswith("ppt/slides/slide") and f.endswith(".xml")]
|
||||
print(f"Total files in zip: {len(names)}")
|
||||
print(f"Slide files found: {len(slide_files)}")
|
||||
print(f"First 5 slide files: {slide_files[:5]}")
|
||||
|
||||
# Test presentation.xml
|
||||
try:
|
||||
pres_xml = z.read("ppt/presentation.xml").decode("utf-8", errors="replace")
|
||||
sld_ids = re.findall(r'<p:sldId\b[^>]*r:id="([^"]+)"', pres_xml)
|
||||
print(f"\nsldIdList rIds: {sld_ids[:5]}")
|
||||
except Exception as e:
|
||||
print(f"\npresentation.xml error: {e}")
|
||||
|
||||
# Test rels
|
||||
try:
|
||||
rels_xml = z.read("ppt/_rels/presentation.xml.rels").decode("utf-8", errors="replace")
|
||||
rid_to_target = dict(re.findall(r'Id="([^"]+)"[^>]*Target="([^"]+)"', rels_xml))
|
||||
print(f"Rels entries: {len(rid_to_target)}")
|
||||
# Show a sample
|
||||
for k, v in list(rid_to_target.items())[:3]:
|
||||
print(f" {k} -> {v}")
|
||||
except Exception as e:
|
||||
print(f"\nrels error: {e}")
|
||||
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" "D:\F\NewI\opencode\daily-workspace\projects\piano-highlight-app\temp\debug_ppt2.py"
|
||||
@@ -0,0 +1,34 @@
|
||||
import zipfile, re, sys
|
||||
|
||||
ppt = r"D:\F\yc\课程上架\福田商圈夜校\课程视频\钢琴演奏入门第一课.pptx"
|
||||
out = r"D:\F\NewI\opencode\daily-workspace\temp\debug_ppt_out.txt"
|
||||
|
||||
results = []
|
||||
|
||||
with zipfile.ZipFile(ppt, "r") as z:
|
||||
names = z.namelist()
|
||||
slide_files = [f for f in names if f.startswith("ppt/slides/slide") and f.endswith(".xml")]
|
||||
results.append(f"Total files in zip: {len(names)}")
|
||||
results.append(f"Slide files found: {len(slide_files)}")
|
||||
results.append(f"First 5: {slide_files[:5]}")
|
||||
|
||||
try:
|
||||
pres_xml = z.read("ppt/presentation.xml").decode("utf-8", errors="replace")
|
||||
sld_ids = re.findall(r'<p:sldId\b[^>]*r:id="([^"]+)"', pres_xml)
|
||||
results.append(f"sldIds: {sld_ids[:5]}")
|
||||
except Exception as e:
|
||||
results.append(f"pres error: {e}")
|
||||
|
||||
try:
|
||||
rels_xml = z.read("ppt/_rels/presentation.xml.rels").decode("utf-8", errors="replace")
|
||||
rid_to_target = dict(re.findall(r'Id="([^"]+)"[^>]*Target="([^"]+)"', rels_xml))
|
||||
results.append(f"rels count: {len(rid_to_target)}")
|
||||
for k, v in list(rid_to_target.items())[:3]:
|
||||
results.append(f" {k} -> {v}")
|
||||
except Exception as e:
|
||||
results.append(f"rels error: {e}")
|
||||
|
||||
with open(out, "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(results))
|
||||
|
||||
print("Done, see", out)
|
||||
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" "D:\F\NewI\opencode\daily-workspace\projects\piano-highlight-app\temp\debug_slide1.py" > "D:\F\NewI\opencode\daily-workspace\temp\debug_slide1_out.txt" 2>&1
|
||||
@@ -0,0 +1,23 @@
|
||||
import zipfile, re, os
|
||||
|
||||
ppt = r"D:\F\yc\课程上架\福田商圈夜校\课程视频\钢琴演奏入门第一课.pptx"
|
||||
out_dir = r"D:\F\NewI\opencode\daily-workspace\temp"
|
||||
slide1_out = os.path.join(out_dir, "slide1_texts.txt")
|
||||
xml_out = os.path.join(out_dir, "slide1_xml_preview.txt")
|
||||
|
||||
with zipfile.ZipFile(ppt, "r") as z:
|
||||
slide1_file = "ppt/slides/slide1.xml"
|
||||
content = z.read(slide1_file).decode("utf-8", errors="replace")
|
||||
all_texts = re.findall(r"<a:t[^>]*>([^<]*)</a:t>", content)
|
||||
|
||||
meaningful = [t for t in all_texts if t.strip()]
|
||||
with open(slide1_out, "w", encoding="utf-8") as f:
|
||||
f.write(f"Total fragments: {len(all_texts)}\n")
|
||||
f.write(f"Meaningful fragments: {len(meaningful)}\n\n")
|
||||
for i, t in enumerate(meaningful):
|
||||
f.write(f"[{i}] {t}\n")
|
||||
|
||||
with open(xml_out, "w", encoding="utf-8") as f:
|
||||
f.write(content[:8000])
|
||||
|
||||
print("Done")
|
||||
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" "D:\F\NewI\opencode\daily-workspace\projects\piano-highlight-app\temp\do_install.py"
|
||||
@@ -0,0 +1,12 @@
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
venv_python = r"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe"
|
||||
result = subprocess.run(
|
||||
[venv_python, "-m", "pip", "install", "python-pptx"],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
print("STDOUT:", result.stdout)
|
||||
print("STDERR:", result.stderr)
|
||||
print("Return code:", result.returncode)
|
||||
@@ -0,0 +1,6 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
echo Installing python-pptx...
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" -m pip install python-pptx -q
|
||||
echo Done
|
||||
pause
|
||||
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" -m pip install python-pptx
|
||||
echo Exit: %errorlevel%
|
||||
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
"D:\ProgramData\anaconda3\envs\py312_cuda\python.exe" -m pip install python-pptx > "D:\F\NewI\opencode\daily-workspace\temp\pip_out.txt" 2>&1
|
||||
echo Exit: %errorlevel%
|
||||
@@ -0,0 +1,12 @@
|
||||
# Kill all python processes related to our CLI
|
||||
Get-Process python -ErrorAction SilentlyContinue | Stop-Process -Force
|
||||
Start-Sleep 3
|
||||
|
||||
# Verify killed
|
||||
$remaining = Get-Process python -ErrorAction SilentlyContinue
|
||||
if ($remaining) {
|
||||
Write-Host "Still running:"
|
||||
$remaining | ForEach-Object { Write-Host " PID:" $_.Id }
|
||||
} else {
|
||||
Write-Host "All python processes killed"
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
f = open(r'D:\F\NewI\opencode\daily-workspace\temp\cli_run_log.txt', 'r', encoding='utf-8')
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
for l in lines[:35]:
|
||||
print(l.rstrip())
|
||||
Binary file not shown.
Reference in New Issue
Block a user