'update'
This commit is contained in:
@@ -128,6 +128,28 @@ class BookNotesExporter:
|
||||
return md
|
||||
|
||||
|
||||
def sync_source_files(config_module):
|
||||
"""
|
||||
自动同步 iBooks 源数据文件到本地 data 目录
|
||||
"""
|
||||
import shutil
|
||||
import os
|
||||
src_files = [
|
||||
(config_module.IBOOKS_ANNOTATION_DB, config_module.LOCAL_ANNOTATION_DB),
|
||||
(config_module.IBOOKS_ANNOTATION_SHM, config_module.LOCAL_ANNOTATION_SHM),
|
||||
(config_module.IBOOKS_ANNOTATION_WAL, config_module.LOCAL_ANNOTATION_WAL),
|
||||
(config_module.IBOOKS_LIBRARY_DB, config_module.LOCAL_LIBRARY_DB),
|
||||
(config_module.IBOOKS_BOOKS_PLIST, config_module.LOCAL_BOOKS_PLIST)
|
||||
]
|
||||
for src, dst in src_files:
|
||||
if os.path.exists(src):
|
||||
shutil.copy2(src, dst)
|
||||
print(f'已拷贝源数据文件到本地: {dst}')
|
||||
else:
|
||||
print(f'未找到文件: {src}')
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import shutil
|
||||
import datetime
|
||||
@@ -136,22 +158,20 @@ if __name__ == '__main__':
|
||||
from InquirerPy import inquirer # type: ignore
|
||||
|
||||
exporter = BookNotesExporter(config)
|
||||
# 自动覆盖 ./data 下的数据库和plist文件,源为iBooks真实路径
|
||||
src_files = [
|
||||
(config.IBOOKS_ANNOTATION_DB, config.LOCAL_ANNOTATION_DB),
|
||||
(config.IBOOKS_ANNOTATION_SHM, config.LOCAL_ANNOTATION_SHM),
|
||||
(config.IBOOKS_ANNOTATION_WAL, config.LOCAL_ANNOTATION_WAL),
|
||||
(config.IBOOKS_LIBRARY_DB, config.LOCAL_LIBRARY_DB),
|
||||
(config.IBOOKS_BOOKS_PLIST, config.LOCAL_BOOKS_PLIST)
|
||||
]
|
||||
for src, dst in src_files:
|
||||
if os.path.exists(src):
|
||||
shutil.copy2(src, dst)
|
||||
print(f'copy source data file to ./data : {dst}')
|
||||
else:
|
||||
print(f'file not found: {src} ')
|
||||
sync_source_files(config)
|
||||
'''
|
||||
sqlite-shm 和 .sqlite-wal 是 SQLite的临时文件,数据库处于WAL模式且有写入时才存在。
|
||||
没有进程打开数据库或数据库关闭后,这两个文件可能会被SQLite清理。
|
||||
'''
|
||||
|
||||
# 先获取所有书籍元数据
|
||||
# 列出 data 目录下所有文件用于测试,此时shm和wal文件存在
|
||||
#data_dir = config.DATA_DIR if hasattr(config, 'DATA_DIR') else './data'
|
||||
#print(f"\n[data目录文件列表] {data_dir}:")
|
||||
#for root, dirs, files in os.walk(data_dir):
|
||||
# for file in files:
|
||||
# print(os.path.join(root, file))
|
||||
|
||||
# 先获取所有书籍元数据
|
||||
manager = BookListManager(plist_path=config.LOCAL_BOOKS_PLIST, db_path=config.LOCAL_LIBRARY_DB)
|
||||
booksinfo = manager.get_books_info()
|
||||
assetid2name = {}
|
||||
|
||||
Reference in New Issue
Block a user