This commit is contained in:
douboer
2025-09-06 07:57:30 +08:00
parent 84c08c511b
commit d7a0a53368
19 changed files with 670 additions and 4 deletions

View File

@@ -130,8 +130,11 @@ class BookNotesExporter:
if __name__ == '__main__':
import shutil
import datetime
import re
import os.path
from InquirerPy import inquirer # type: ignore
exporter = BookNotesExporter(config)
# 自动覆盖 ./data 下的数据库和plist文件源为iBooks真实路径
src_files = [
@@ -181,6 +184,10 @@ if __name__ == '__main__':
exit(1)
selected_booksnote = exporter.build_booksnote(bookid=selected_assetid)
selected_booksinfo = {selected_assetid: booksinfo.get(selected_assetid, {})}
out_path = f'export_notes/notes_export_{selected_assetid}.md'
bookname = selected_booksinfo[selected_assetid].get("displayname") or selected_booksinfo[selected_assetid].get("itemname") or selected_assetid
ts = datetime.datetime.now().strftime('%m%d%H%M')
# 文件名用[.:_【分割取第一段
shortname = re.split(r'[.:_\\[\(]', bookname)[0].strip()
out_path = os.path.join(config.EXPORT_NOTES_DIR, f'notes_{shortname}-{ts}.md')
exporter.export_booksnote_to_md(selected_booksnote, selected_booksinfo, out_path)
print(f'{selected_booksinfo[selected_assetid].get("displayname") or selected_booksinfo[selected_assetid].get("itemname") or selected_assetid}》 导出笔记 {out_path}')