예제 PDF와 통계 및 표시 속성 한글화와 검증 기록

This commit is contained in:
Codex
2026-09-13 17:19:45 +09:00
parent 77c2892aba
commit 087e80126d
28 changed files with 16165 additions and 83 deletions
@@ -0,0 +1,22 @@
import sqlite3,json,pathlib
base=pathlib.Path('/www/dk_project/dk_app/trilium')
db=sqlite3.connect('file:'+str(base/'data/document.db')+'?mode=ro',uri=True);db.row_factory=sqlite3.Row
out=pathlib.Path('/tmp/trilium-phase4-inspect');out.mkdir(mode=0o700,exist_ok=True)
allowed={n['noteId'] for n in json.load(open('/tmp/trilium-ko-scoped/notes.json'))}
notes=[]
for nid in ['EW0u2LoAZTYv','WJaFVVj6QO1J','ga590IKu7zmy','swKGGdlek7o6']:
assert nid in allowed
row=db.execute('SELECT n.noteId,n.title,n.type,n.mime,b.content FROM notes n LEFT JOIN blobs b ON b.blobId=n.blobId WHERE n.noteId=? AND n.isDeleted=0 AND n.isProtected=0',(nid,)).fetchone();assert row
item=dict(row)
if nid=='swKGGdlek7o6':
assert item['mime']=='application/pdf';(out/'demo.pdf').write_bytes(item.pop('content'))
elif isinstance(item['content'],bytes):item['content']=item['content'].decode('utf8')
notes.append(item)
attrs=[]
for aid in ['teXYgLEYyqww','Gt3n5YmjWd92','mNukzJtxNy9F','84Eslb7zduKM','oOhOmvlQA1l7','ovlzSwPHBESP','1YTM1UQRQtnt','KbYhsredrwOt','UE1YHe51q07k','PmBHwLv8Dtf3']:
row=dict(db.execute('SELECT attributeId,noteId,name,value FROM attributes WHERE attributeId=? AND isDeleted=0',(aid,)).fetchone());assert row['noteId'] in allowed;attrs.append(row)
branches=[]
for bid in ['E1e6RXYb7KDR_HlLfbi37EMDe','Zqbx4QzZLAw2_0za9R4spbuOD','GIfEhKrDNdnn_2JsGaSEmZSku','GIfEhKrDNdnn_hpxIn2I2IdAJ','m6DbuIecq3cC_BdeGRs0x9xSN']:
row=dict(db.execute('SELECT branchId,noteId,prefix FROM branches WHERE branchId=? AND isDeleted=0',(bid,)).fetchone());assert row['noteId'] in allowed;branches.append(row)
(out/'data.json').write_text(json.dumps({'notes':notes,'attributes':attrs,'branches':branches},ensure_ascii=False))
print(json.dumps({'notes':len(notes),'attributes':len(attrs),'branches':len(branches),'pdfBytes':(out/'demo.pdf').stat().st_size}))