{"id":24469166,"url":"https://github.com/alex-guoba/sync-notion","last_synced_at":"2025-04-13T10:24:24.724Z","repository":{"id":192360649,"uuid":"686579300","full_name":"alex-guoba/sync-notion","owner":"alex-guoba","description":"Syncing Wechat Book Notes, Github Trending, Memos to Notion automatically. 支持将微信读书笔记（划线评论、阅读详情等）、github trending、memos发表同步到Notion。","archived":false,"fork":false,"pushed_at":"2025-04-10T01:49:28.000Z","size":532,"stargazers_count":28,"open_issues_count":0,"forks_count":11,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T02:49:50.987Z","etag":null,"topics":["memos","notion","weread"],"latest_commit_sha":null,"homepage":"https://goroutine.cn/notes","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alex-guoba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-03T09:11:09.000Z","updated_at":"2025-04-10T01:49:31.000Z","dependencies_parsed_at":"2023-10-11T12:45:06.794Z","dependency_job_id":"8612e0bb-39eb-4dcd-83c7-321097d3790e","html_url":"https://github.com/alex-guoba/sync-notion","commit_stats":null,"previous_names":["alex-guoba/sync-notion"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-guoba%2Fsync-notion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-guoba%2Fsync-notion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-guoba%2Fsync-notion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-guoba%2Fsync-notion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alex-guoba","download_url":"https://codeload.github.com/alex-guoba/sync-notion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248696692,"owners_count":21147161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["memos","notion","weread"],"created_at":"2025-01-21T07:14:32.572Z","updated_at":"2025-04-13T10:24:24.691Z","avatar_url":"https://github.com/alex-guoba.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Example Page\" src=\"https://github.com/alex-guoba/sync-notion/assets/2872637/4bcb0692-8881-4f39-abce-22495c8a3fcc\" width=\"689\"\u003e\n\u003c/p\u003e\n\n\n# 将微信读书笔记、github trending、memos自动同步到Notion\n\n本项目支持将微信读书笔记（划线及评论）、github trending以及memos同步Notion。支持本地手工、github action定期两种方式。可以修改action配置自行按需选择。\n\n[English](./README.md) | 简体中文\n\n## Requirements\n\nPython 3.10\n\n## 同步微信读书笔记\n\n### 使用\n\n1. star本项目\n\n2. fork这个工程，删除目录中的临时存储文件(./var/sync_read.db)\n\n3. 获取微信读书的Cookie: `WEREAD_COOKIE`\n\n- 浏览器打开 https://weread.qq.com/\n- 微信扫码登录确认，提示没有权限忽略即可\n- 按F12进入开发者模式，依次点 Network -\u003e Doc -\u003e Headers-\u003e cookie。复制 Cookie 字符串;\n\n4. 获取NotionToken: `NOTION_TOKEN`\n\n- 浏览器打开https://www.notion.so/my-integrations\n- 点击New integration 输入name提交\n- 点击show，然后copy\n\n5. 复制[这个Notion模板](https://gelco.notion.site/67639069c7b84f55b6394f16ecda0c4f?v=b5d09dc635db4b3d8ba13b200b88d823\u0026pvs=25)，删掉所有的数据，并点击右上角设置，Connections添加你创建的Integration。\n\n6. 获取NotionDatabaseID: `NOTION_DATABASE_ID`\n\n- 打开Notion数据库，点击右上角的Share，然后点击Copy link\n- 获取链接后比如https://gelco.notion.site/67639069c7b84f55b6394f16ecda0c4f?v=b5d09dc635db4b3d8ba13b200b88d823\u0026pvs=25 中间的**67639069c7b84f55b6394f16ecda0c4f**就是DatabaseID\n\n7. 同步方式\n\n- **方式一**：在Github的Secrets中添加以下变量来实现每日自动同步\n\n  - 打开你fork的工程，点击Settings-\u003eSecrets and variables-\u003eNew repository secret\n  - 添加以下变量(**变量名称自定义，只要与action中对应的名称一致即可**)\n    - `WEREAD_COOKIE`\n    - `NOTION_TOKEN`\n    - `NOTION_DATABASE_ID`\n\n- **方式二**： 也可以本地运行脚本完成同步: \n\n```shell\npip install -r requirements.txt\npython3 ./main.py sync_weread ${WEREAD_COOKIE} ${NOTION_TOKEN} ${NOTION_DATABASE_ID}\n```\n\n### 高级特性\n\n1. 可以配合 [next-blogger](https://github.com/alex-guoba/next-blogger) 搭建自己的**读书笔记分享**网站。样式参考 [goroutine.cn](https://goroutine.cn/notes)\n\n2. 【可选】可以指定单独的Notion数据库，用于存储每日同步记录，用作calender视图等场景。\n\n- action中环境变量`NOTION_DATABASE_CALENDAR`，命令行方式参考[action](./.github/workflows/weread.yml)。模板参考[这个](https://gelco.notion.site/5a17a1f794464652ade156c4c7572736?v=d961ee4d64864620b948b1a18fb1ebdd\u0026pvs=4)\n\n- 注意：也需要在Connections添加你创建的Integration。流程与上面一致。\n\n3. 支持[Server酱](https://sct.ftqq.com/)微信通知，用于在同步完成时发送微信通知更新读书笔记数。\n\n- action中环境变量`SCKEY`，参考[action](./.github/workflows/weread.yml)。申请方式参考[Server酱](https://sct.ftqq.com/sendkey)。\n\n\n### 增量同步说明\n\n#### 更新时机\n1. 微信读书笔记为增量同步，每次同步时，会根据笔记的更新时间进行筛选。仅当微信读书中书籍有**笔记更新**时才会触发同步。\n2. 可以删除db中已同步过的书籍页面(page)，删除后下次同步时会全同步（注意需要在微信读书中触发一次笔记更新，比如新增、删除任意笔记即可）。\n\n#### 增量机制\n1. 已同步到Notion的笔记，用户可以在Notion中**新增、修改**笔记内容，下次同步时，**不会覆盖已同步过的笔记**。\n2. 增量笔记同步顺序：新增章节会按照微信读书的章节顺序插入；新增笔记会插入到对应的章节下，但不保证同一章节下的笔记与微信读书一致。\n3. 用户可以在database中新增字段，用做书籍的自定义标识。但不得修改已有字段。\n4. 已同步到Notion的笔记，**用户不得删除章节信息**，否则下次同步同一章节的增量笔记无法精确定位。\n\n### 原理说明\nNotion无法保存微信读书的笔记id等信息，所以在仓库中存储了一份微信读书笔记ID与[Notion Block ID](https://developers.notion.com/reference/patch-block-children)的映射关系。每次更新完毕后在git action中自动提交到仓库。\n所以如果用户clone了本仓库到，首次运行时可以先删除原仓库中的映射文件(./var/sync_read.db)。\n\n### 支持的配置项\n\n```ini\n[weread.format]\nContentType = list\nEnableEmoj = false\nEnableReadingDetail = true\n```\n\n- ContentType：增加笔记内容block组织形式配置，可以将内容展现形态指定为paragraph/list/callout。\n- EnableEmoj：开启、禁用emoj\n- EnableReadingDetail: 开启、禁用阅读明细。\n\n\n## 同步Github Trending\n\n### 使用\n\n与微信读书同步方法基本一致。\n\n1. 获取NotionToken（可复用）\n\n2. 创建NotionDatabase，获取NotionDatabaseID， notion模板参考[这个](https://gelco.notion.site/77a3c6c8c2fb405e8347a7bde96d51d1?v=5c6464969afa432ea473f07c7b6959e8)\n\n3. 本地运行方式\n\n```shell\npip install -r requirements.txt\npython3 ./main.py sync_trending ${NOTION_TOKEN} ${NOTION_DATABASE_TRENDING} --git_token=${GIT_TOKEN}\n```\n\n4. 或者在Github的Secrets中添加以下变量来实现每日自动同步\n\n* 打开你fork的工程，点击Settings-\u003eSecrets and variables-\u003eNew repository secret\n* 添加以下变量 (**变量名称自定义，只要与action中对应的名称一致即可**)\n  * NOTION_TOKEN\n  * NOTION_DATABASE_TRENDING\n  * GIT_TOKEN\n如果不需要仓库的其他信息（包括fork、star、watcher数量），GIT_TOKEN可以不配置\n\n\n### 支持的配置项\n\n```ini\n[trending.language]\nlanguages = python,go\n```\n\n- languages: 关注的项目语言，不允许为空\n\n\n## 同步Memos发表到Notion\n\n### 使用\n\n与微信读书同步方法基本一致。\n\n1. 获取NotionToken（可复用）\n\n2. 创建NotionDatabase，获取NotionDatabaseID， notion模板参考[这个](https://gelco.notion.site/b840c05d92af44719ee3d9d7f73010f8?v=f0a726764fa3455b9a28f50783eea58a\u0026pvs=4)\n\n3. 在Memos平台为用户分配一个独立的[Token](https://usememos.com/docs/access-tokens)供访问Memos使用。\n   \n4. 修改配置文件，设置memos host地址以及拉取人UserName。注意分配Token的用户身份与拉取人UserName一致才可以拉取到Private memo。\n\n5. 本地运行\n```shell\npython3 ./main.py sync_memos ${NOTION_TOKEN} ${DATABASE_ID} ${MEMOS_TOKEN}\n```\n\n```ini\n[memos.opts]\nMemosHost = http://127.0.0.1:8081\n; 用户名，而非昵称\nMemosUserName = memos-demo\n```\n\n也可配置github action来实现定期同步，有需要修改github action以及配置对应环境即可。\n\n```shell\n# git中配置好对应的环境变量，设置对应的action run指令即可\npython3 ./main.py sync_memos \"${{secrets.NOTION_TOKEN}}\" \"${{DATABASE_ID}}\" \"${{MEMOS_TOKEN}}\"\n```\n\n\n## 同步ProductHunt产品列表到Notion\n\n### 使用\n\n与微信读书同步方法基本一致。产品列表参考[ProductHunt](https://www.producthunt.com/all)\n\n1. 获取NotionToken（可复用）\n\n2. 创建NotionDatabase，获取NotionDatabaseID， notion模板参考[这个](https://gelco.notion.site/1467b35a24cd80449eeadf5ed024cef5?v=1a470daa9fc0418d8682aaf789860d40\u0026pvs=73)\n   \n3. 本地运行\n```shell\npython3 ./main.py sync_producthunt ${NOTION_TOKEN} ${DATABASE_ID}\n```\n\n```ini\n[producthunt.filter]\n; 过滤条件，可选\nMinVotes = 5\nMinComments = 5\n```\n\n也可配置github action来实现定期同步，有需要修改github action以及配置对应环境即可。\n\n```shell\n# git中配置好对应的环境变量，设置对应的action run指令即可\npython3 ./main.py sync_producthunt \"${{secrets.NOTION_TOKEN}}\" \"${{DATABASE_ID_PH}}\"\n```\n\n\n## 感谢\n\n- [malinkang / weread_to_notion](https://github.com/malinkang/weread_to_notion)\n- [bonfy / github-trending](https://github.com/bonfy/github-trending)\n- [usememos / memos](https://github.com/usememos/memos)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex-guoba%2Fsync-notion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falex-guoba%2Fsync-notion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex-guoba%2Fsync-notion/lists"}