This commit is contained in:
douboer
2025-08-15 13:49:02 +08:00
parent 8873c70a60
commit 0bc6844209
76 changed files with 726 additions and 11197 deletions

View File

@@ -6,12 +6,15 @@ annotationdata.py
- 提供parse_location辅助函数解析笔记定位信息。
- 返回结构化的annotations数据便于后续章节定位与导出。
依赖config.py 统一管理路径和配置项。
主要接口:
- get_annotations(db_path, bookid=None)返回所有或指定assetid的笔记结构为{assetid: {uuid: {...}}}
- parse_location(location)解析ZANNOTATIONLOCATION返回(idref, filepos)
依赖sqlite3, collections, re, os, datetime
"""
import config
import sqlite3
from collections import defaultdict
@@ -34,7 +37,7 @@ def parse_location(location):
filepos = matches[1] if len(matches) > 1 else None
return idref, filepos
def get_annotations(db_path='./data/AEAnnotation.sqlite', bookid=None):
def get_annotations(db_path=config.LOCAL_ANNOTATION_DB, bookid=None):
# 检查WAL模式相关文件
base = db_path.rsplit('.', 1)[0]
wal_path = base + '.sqlite-wal'