用来把 Notion 数据库的书籍、电影评价同步到豆瓣。
由于豆瓣无法支持修改评价日期以及记录多次评价,本工具把 Notion 数据库中的重复项的评价按日期倒序合并,作为在豆瓣的“短评”,并用最近一次的评价作为豆瓣评价。
git clone https://github.com/stdrc/notion-douban-sync.git
cd notion-douban-sync
# 安装 Node 依赖
npm install
# 安装 Python 依赖
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
先摆了,可以网上搜索如何获得。获得后,拷贝 .env.example
为 .env
,填入到对应项。
node get_notion_reviews.js movie <database_id>
这里 movie
可以改成 book
。脚本假设数据库 schema 和 我的 一致,如果不一致,可以自行修改脚本或者用其它方式导出为兼容的 JSON 文件。
JSON 文件形如:
[
{
"name": "死亡诗社",
"douban_url": "https://movie.douban.com/subject/1291548/",
"rating_date": "2023-07-23",
"rating": "👍 值得一看",
"rating_score": 1,
"public_url": "https://stdrc.notion.site/1d7942b7347546fe928ed38131b6b6c7"
}
]
其中 rating
可以是任何字符串,后面的脚本是依据 rating_score
在豆瓣评分;rating_score
采用 -2 到 +2 的评价方式,-2 表示极差,-1 表示较差,0 表示无感,1 表示较好,2 表示极好;public_url
是可以公开访问的影评/书评链接,目前没用到,可以留空。
python3 sync_to_douban.py --dry-run movie
注意这里加了 --dry-run
表示只打印到控制台,不真的请求豆瓣 API,去掉会真的往豆瓣同步。可以通过 python sync_to_douban.py --help
查看更多用法,比如限制只同步一定时间范围内的数据:
python3 sync_to_douban.py \
--dry-run \
--start-date 2022-01-01 \
--end-date 2022-12-31 \
movie
如果只需要同步今天刚评价的内容:
python3 sync_to_douban.py \
--dry-run \
--start-date today \
movie