iBook/config.py

63 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 统计用:无笔记但当天有打开书籍时的阅读时长(单位:分钟)
READ_TIME_OPEN_DAY = 15
"""
config.py
---------
统一管理所有涉及文件路径、目录、常量等配置项。
"""
import os
# 数据目录
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
EXPORT_NOTES_DIR = os.path.join(os.path.dirname(__file__), 'notes')
EXAMPLES_DIR = os.path.join(os.path.dirname(__file__), 'examples')
# 应用图标
APP_ICON = os.path.join(os.path.dirname(__file__), 'icons', 'Cbb20.png')
# iBooks 源数据路径(可根据实际环境修改)
IBOOKS_ANNOTATION_DB = os.path.expanduser('~/Library/Containers/com.apple.iBooksX/Data/Documents/AEAnnotation/AEAnnotation_v10312011_1727_local.sqlite')
IBOOKS_ANNOTATION_SHM = IBOOKS_ANNOTATION_DB + '-shm'
IBOOKS_ANNOTATION_WAL = IBOOKS_ANNOTATION_DB + '-wal'
IBOOKS_LIBRARY_DB = os.path.expanduser('~/Library/Containers/com.apple.iBooksX/Data/Documents/BKLibrary/BKLibrary-1-091020131601.sqlite')
IBOOKS_LIBRARY_SHM = IBOOKS_LIBRARY_DB + '-shm'
IBOOKS_LIBRARY_WAL = IBOOKS_LIBRARY_DB + '-wal'
IBOOKS_BOOKS_PLIST = os.path.expanduser('~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books/Books.plist')
IBOOKS_BOOKS_DIR = os.path.expanduser('~/Library/Mobile Documents/iCloud~com~apple~iBooks/Documents')
# 本地数据文件名
LOCAL_ANNOTATION_DB = os.path.join(DATA_DIR, 'AEAnnotation.sqlite')
LOCAL_ANNOTATION_SHM = os.path.join(DATA_DIR, 'AEAnnotation.sqlite-shm')
LOCAL_ANNOTATION_WAL = os.path.join(DATA_DIR, 'AEAnnotation.sqlite-wal')
LOCAL_LIBRARY_DB = os.path.join(DATA_DIR, 'BKLibrary.sqlite')
LOCAL_LIBRARY_SHM = os.path.join(DATA_DIR, 'AEAnnotation.sqlite-shm')
LOCAL_LIBRARY_WAL = os.path.join(DATA_DIR, 'AEAnnotation.sqlite-wal')
LOCAL_BOOKS_PLIST = os.path.join(DATA_DIR, 'Books.plist')
# 统计用:每日最小阅读时长(单位:秒)
READ_TIME_DAY = 60
# 阿里 DashScope API Key优先读取环境变量若未设置则使用下面的默认值
# 注意:为安全起见,生产或开源仓库不要直接硬编码真实密钥,建议只保留 os.environ 读取逻辑。
DASHSCOPE_API_KEY = os.environ.get('DASHSCOPE_API_KEY', 'sk-2546da09b6d9471894aeb95278f96c11')
# ---------------- 字体配置 ----------------
# 可选字体列表(用户可在配置对话框中输入其一);若系统不存在则按回退顺序尝试。
FONT_CANDIDATES = [
'PingFang SC', # macOS 系统中文苹方 (简体)
'PingFang TC', # 繁体
'PingFang HK',
'PingFang', # 有些场景可能只暴露基名
'Fira Code',
'JetBrains Mono',
'Comic Mono',
'Input Sans',
]
# 当前使用的主字体(默认首选苹方简体),字体大小默认
FONT_FAMILY = os.environ.get('APP_FONT_FAMILY', 'PingFang SC')
FONT_SIZE = int(os.environ.get('APP_FONT_SIZE', '14'))