SYAK:同步 SiYuan 内容块到 Anki, 自动更新, 自动删除
> 如果觉得有帮助, 麻烦点个 Star⭐
>
⚠ **初次使用请提前备份 Anki, 以免数据误删!**
# Prerequisite
1. Anki 需要安装 AnkiConnect 插件, code 为 `2055492159`, 默认端口 `8765`
2. 支持 Python 3.9 以上版本
3. SiYuan 默认端口为 `6806`
4. 同步时, 保持 SiYuan 和 Anki 同时运行
# Install
```
pip install -U syak
```
# Usage
1. 新建一个 `card` 文档块, 名字支持前后缀, 例如 `@card`
2. 在需要制卡的内容块后面引用 `card` 文档块
3. 制卡内容块为某个容器块下的叶子块时, 卡片正面为制卡内容块, 背面为整个容器块
4. 制卡内容块为文档块下的叶子块时, 卡片正面为制卡内容块, 背面为空
5. 运行命令 `syak -p SiYuan数据根路径(data目录的上一级)` 即可同步
6. 运行周期任务 `syak -p SiYuan数据根路径(data目录的上一级) -i (seconds)`, 例如每 5 分钟运行一次 `syak -p SiYuan数据根路径(data目录的上一级) -i 300`
7. 后台运行
1. Linux&macOS `nohup syak -p SiYuan数据根路径(data目录的上一级) -i (seconds) &`
2. Windows `start /b syak -p SiYuan数据根路径(data目录的上一级) -i (seconds)`
8. 指定 deck 层级: `syak -p SiYuan数据根路径(data目录的上一级) --custom_deck 笔记本名/指定层级`
1. 例如: 原始层级为 `notebook/daily/2022/2022-12-28`, 如果不想创建 `2022` 和 `2022-12-08` 两个 child deck, 可以使用 `syak -p SiYuan数据根路径(data目录的上一级) --custom_deck notebook/daily`
9. 查看更多选项运行 `syak -h`
# Demo
![demo](demo.gif)
# Feature
1. 添加 SiYuan URL 跳转链接
2. 自动更新, SiYuan 更新内容块后, Anki 自动更新
3. 自动删除, 删除 `card` 引用块, Anki 自动删除
4. 根据文档块层级自动建立 deck 层级
5. 支持 media 文件
6. 自动删除 empty deck
7. 同步完成时, 发送同步信息给 SiYuan, 停留 5s
# Not Support (currently)
1. Close
2. 代码块语法高亮
3. 超级块未适配
# More
1. macOS 用户如果遇到同步耗时较长的问题, 可以参考:
1. [FooSoft Productions - Anki-Connect](https://foosoft.net/projects/anki-connect/)
> Starting with [Mac OS X Mavericks](https://en.wikipedia.org/wiki/OS_X_Mavericks), a feature named *App Nap* has been introduced to the operating system. This feature causes certain applications which are open (but not visible) to be placed in a suspended state. As this behavior causes Anki-Connect to stop working while you have another window in the foreground, App Nap should be disabled for Anki:
>
> 1. Start the Terminal application.
> 2. Execute the following commands in the terminal window:
>
> ```
> defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
> defaults write net.ichi2.anki NSAppSleepDisabled -bool true
> defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true
> ```
> 3. Restart Anki.
>
# Changelog
* 更新到 0.1.8 🎉 🎉 🎉
升级:`pip install -U syak`
1. 支持自定义 deck 层级
使用方式: `syak -p SiYuan数据根路径(data目录的上一级) --custom_deck 笔记本名/指定层级`, 例如: 原始层级为 `notebook/daily/2022/2022-12-28`, 如果不想创建 `2022` 和 `2022-12-08` 两个 child deck, 可以使用 `syak -p SiYuan数据根路径(data目录的上一级) --custom_deck notebook/daily`
2. 修复删除空行引起的错误格式
* 更新到 0.1.7 🎉 🎉 🎉
升级:`pip install -U syak`
1. 增加周期任务
1. 运行周期任务 `syak -p SiYuan数据根路径(data目录的上一级) -i (seconds)`, 例如每 5 分钟运行一次 `syak -p SiYuan数据根路径(data目录的上一级) -i 300`
2. 后台运行
1. Linux&macOS `nohup syak -p SiYuan数据根路径(data目录的上一级) -i (seconds) &`
2. Windows `start /b syak -p SiYuan数据根路径(data目录的上一级) -i (seconds)` 未测试
Raw data
{
"_id": null,
"home_page": "https://github.com/why8023/SYAK",
"name": "syak",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "Anki,SiYuan",
"author": "why8023",
"author_email": "whyniaaa@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/93/58/3194aae77f889b9f458de87fa0ae374442e3d83cb86d68118d0c8cf154b3/syak-0.1.9.tar.gz",
"platform": null,
"description": "SYAK:\u540c\u6b65 SiYuan \u5185\u5bb9\u5757\u5230 Anki, \u81ea\u52a8\u66f4\u65b0, \u81ea\u52a8\u5220\u9664\n\n> \u5982\u679c\u89c9\u5f97\u6709\u5e2e\u52a9, \u9ebb\u70e6\u70b9\u4e2a Star\u2b50\n>\n\n\u26a0 **\u521d\u6b21\u4f7f\u7528\u8bf7\u63d0\u524d\u5907\u4efd Anki, \u4ee5\u514d\u6570\u636e\u8bef\u5220!**\n\n# Prerequisite\n\n1. Anki \u9700\u8981\u5b89\u88c5 AnkiConnect \u63d2\u4ef6, code \u4e3a `2055492159`\u200b\u200b\u200b\u200b, \u9ed8\u8ba4\u7aef\u53e3 `8765`\u200b\u200b\u200b\u200b\n2. \u652f\u6301 Python 3.9 \u4ee5\u4e0a\u7248\u672c\n3. SiYuan \u9ed8\u8ba4\u7aef\u53e3\u4e3a `6806`\u200b\u200b\u200b\u200b\n4. \u540c\u6b65\u65f6, \u4fdd\u6301 SiYuan \u548c Anki \u540c\u65f6\u8fd0\u884c\n\n# Install\n\n```\npip install -U syak\n```\n\n# Usage\n\n1. \u65b0\u5efa\u4e00\u4e2a `card`\u200b\u200b\u200b\u200b \u200b\u6587\u6863\u5757, \u540d\u5b57\u652f\u6301\u524d\u540e\u7f00, \u4f8b\u5982 `@card`\u200b\u200b\u200b\u200b\u200b\n2. \u5728\u9700\u8981\u5236\u5361\u7684\u5185\u5bb9\u5757\u540e\u9762\u5f15\u7528 `card`\u200b\u200b\u200b\u200b \u200b\u6587\u6863\u5757\n3. \u5236\u5361\u5185\u5bb9\u5757\u4e3a\u67d0\u4e2a\u5bb9\u5668\u5757\u4e0b\u7684\u53f6\u5b50\u5757\u65f6, \u5361\u7247\u6b63\u9762\u4e3a\u5236\u5361\u5185\u5bb9\u5757, \u80cc\u9762\u4e3a\u6574\u4e2a\u5bb9\u5668\u5757\n4. \u5236\u5361\u5185\u5bb9\u5757\u4e3a\u6587\u6863\u5757\u4e0b\u7684\u53f6\u5b50\u5757\u65f6, \u5361\u7247\u6b63\u9762\u4e3a\u5236\u5361\u5185\u5bb9\u5757, \u80cc\u9762\u4e3a\u7a7a\n5. \u8fd0\u884c\u547d\u4ee4 `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7)`\u200b\u200b\u200b\u200b \u200b\u5373\u53ef\u540c\u6b65\n6. \u8fd0\u884c\u5468\u671f\u4efb\u52a1 `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) -i (seconds)`\u200b\u200b\u200b, \u4f8b\u5982\u6bcf 5 \u5206\u949f\u8fd0\u884c\u4e00\u6b21 `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) -i 300`\u200b\u200b\u200b\n7. \u540e\u53f0\u8fd0\u884c\n\n 1. Linux&macOS `nohup syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) -i (seconds) &`\u200b\u200b\u200b\n 2. Windows `start /b syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) -i (seconds)`\u200b\u200b\u200b\n8. \u6307\u5b9a deck \u5c42\u7ea7: `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) --custom_deck \u7b14\u8bb0\u672c\u540d/\u6307\u5b9a\u5c42\u7ea7`\u200b\n\n 1. \u4f8b\u5982: \u539f\u59cb\u5c42\u7ea7\u4e3a `notebook/daily/2022/2022-12-28`\u200b, \u5982\u679c\u4e0d\u60f3\u521b\u5efa `2022`\u200b \u548c `2022-12-08`\u200b \u4e24\u4e2a child deck, \u53ef\u4ee5\u4f7f\u7528 `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) --custom_deck notebook/daily`\u200b\n9. \u67e5\u770b\u66f4\u591a\u9009\u9879\u8fd0\u884c `syak -h`\u200b\u200b\u200b\u200b\u200b\n\n# Demo\n\n\u200b![demo](demo.gif)\u200b\n\n# Feature\n\n1. \u6dfb\u52a0 SiYuan URL \u8df3\u8f6c\u94fe\u63a5\n2. \u81ea\u52a8\u66f4\u65b0, SiYuan \u66f4\u65b0\u5185\u5bb9\u5757\u540e, Anki \u81ea\u52a8\u66f4\u65b0\n3. \u81ea\u52a8\u5220\u9664, \u5220\u9664 `card`\u200b \u200b\u5f15\u7528\u5757, Anki \u81ea\u52a8\u5220\u9664\n4. \u6839\u636e\u6587\u6863\u5757\u5c42\u7ea7\u81ea\u52a8\u5efa\u7acb deck \u5c42\u7ea7\n5. \u652f\u6301 media \u6587\u4ef6\n6. \u81ea\u52a8\u5220\u9664 empty deck\n7. \u540c\u6b65\u5b8c\u6210\u65f6, \u53d1\u9001\u540c\u6b65\u4fe1\u606f\u7ed9 SiYuan, \u505c\u7559 5s\n\n# Not Support (currently)\n\n1. Close\n2. \u4ee3\u7801\u5757\u8bed\u6cd5\u9ad8\u4eae\n3. \u8d85\u7ea7\u5757\u672a\u9002\u914d\n\n# More\n\n1. macOS \u7528\u6237\u5982\u679c\u9047\u5230\u540c\u6b65\u8017\u65f6\u8f83\u957f\u7684\u95ee\u9898, \u53ef\u4ee5\u53c2\u8003:\n\n 1. [FooSoft Productions - Anki-Connect](https://foosoft.net/projects/anki-connect/)\n\n > Starting with [Mac OS X Mavericks](https://en.wikipedia.org/wiki/OS_X_Mavericks), a feature named *App Nap* has been introduced to the operating system. This feature causes certain applications which are open (but not visible) to be placed in a suspended state. As this behavior causes Anki-Connect to stop working while you have another window in the foreground, App Nap should be disabled for Anki:\n >\n > 1. Start the Terminal application.\n > 2. Execute the following commands in the terminal window:\n >\n > ```\n > defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true\n > defaults write net.ichi2.anki NSAppSleepDisabled -bool true\n > defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true\n > ```\n > 3. Restart Anki.\n >\n\n# Changelog\n\n* \u66f4\u65b0\u5230 0.1.8 \ud83c\udf89 \ud83c\udf89 \ud83c\udf89\n\n \u5347\u7ea7:`pip install -U syak`\u200b\n\n 1. \u652f\u6301\u81ea\u5b9a\u4e49 deck \u5c42\u7ea7\n\n \u4f7f\u7528\u65b9\u5f0f: `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) --custom_deck \u7b14\u8bb0\u672c\u540d/\u6307\u5b9a\u5c42\u7ea7`\u200b, \u4f8b\u5982: \u539f\u59cb\u5c42\u7ea7\u4e3a `notebook/daily/2022/2022-12-28`\u200b, \u5982\u679c\u4e0d\u60f3\u521b\u5efa `2022`\u200b \u548c `2022-12-08`\u200b \u4e24\u4e2a child deck, \u53ef\u4ee5\u4f7f\u7528 `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) --custom_deck notebook/daily`\u200b\n 2. \u4fee\u590d\u5220\u9664\u7a7a\u884c\u5f15\u8d77\u7684\u9519\u8bef\u683c\u5f0f\n* \u66f4\u65b0\u5230 0.1.7 \ud83c\udf89 \ud83c\udf89 \ud83c\udf89\n\n \u5347\u7ea7:`pip install -U syak`\u200b\u200b\n\n 1. \u589e\u52a0\u5468\u671f\u4efb\u52a1\n\n 1. \u8fd0\u884c\u5468\u671f\u4efb\u52a1 `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) -i (seconds)`\u200b\u200b\u200b, \u4f8b\u5982\u6bcf 5 \u5206\u949f\u8fd0\u884c\u4e00\u6b21 `syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) -i 300`\u200b\u200b\u200b\n 2. \u540e\u53f0\u8fd0\u884c\n\n 1. Linux&macOS `nohup syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) -i (seconds) &`\u200b\u200b\n 2. Windows `start /b syak -p SiYuan\u6570\u636e\u6839\u8def\u5f84(data\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7) -i (seconds)`\u200b\u200b \u672a\u6d4b\u8bd5\n\n\u200d",
"bugtrack_url": null,
"license": "MIT",
"summary": "SiYuan sync to Anki",
"version": "0.1.9",
"split_keywords": [
"anki",
"siyuan"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "436a749d9d9a4816d97a5105d6f18c353ee1148805d44a9a7c66f8c7d45abfef",
"md5": "dc7d6647e82166488b420cdfe7eb6d99",
"sha256": "a99e85bcfb5bd3fb76f354b81c71c31ada00c3392faa326ad442191972e7fb3d"
},
"downloads": -1,
"filename": "syak-0.1.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dc7d6647e82166488b420cdfe7eb6d99",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 8701,
"upload_time": "2023-01-11T09:52:53",
"upload_time_iso_8601": "2023-01-11T09:52:53.263380Z",
"url": "https://files.pythonhosted.org/packages/43/6a/749d9d9a4816d97a5105d6f18c353ee1148805d44a9a7c66f8c7d45abfef/syak-0.1.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "93583194aae77f889b9f458de87fa0ae374442e3d83cb86d68118d0c8cf154b3",
"md5": "3437b40e8f45652494798ef5c4b221bf",
"sha256": "34ae678dbae9c6fa757974ec63d479dd79a3903fe6e8fbc182884fbc7310b5b4"
},
"downloads": -1,
"filename": "syak-0.1.9.tar.gz",
"has_sig": false,
"md5_digest": "3437b40e8f45652494798ef5c4b221bf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 9290,
"upload_time": "2023-01-11T09:52:55",
"upload_time_iso_8601": "2023-01-11T09:52:55.807606Z",
"url": "https://files.pythonhosted.org/packages/93/58/3194aae77f889b9f458de87fa0ae374442e3d83cb86d68118d0c8cf154b3/syak-0.1.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-11 09:52:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "why8023",
"github_project": "SYAK",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "syak"
}