![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
我已经开始大量使用黑曜石,因为这是一个很棒的笔记实用程序,并具有许多高级功能,插件和社区支持。
I've started using Obsidian quite a lot, as it's a fantastic note-taking utility with a lot of advanced features, plugins, and community support. I know others who use Notion, and while I've been trying to get to grips with it, there are some things I'd like to keep in both services at all times. That's why I wrote a Python script that allows me to synchronize my to-do list from Obsidian to a Notion database.
我已经开始大量使用黑曜石,因为这是一个很棒的笔记实用程序,并具有许多高级功能,插件和社区支持。我知道其他使用概念的人,当我一直试图掌握它时,我想始终保持两种服务。这就是为什么我编写了一个Python脚本,使我能够将我的待办事项清单从Obsidian同步到一个概念数据库。
In order to use this script, you'll need to follow the instructions outlined below in order to generate an integration token for your Notion database. You can then give your integration access to your selected database, and it will be able to read and write to it as it needs to. Notion has a lot of different integrations readily available, but we're going to be creating our own combined with a pre-made template.
为了使用此脚本,您需要遵循以下概述的说明,以便为您的概念数据库生成集成令牌。然后,您可以使您可以对所选数据库进行集成访问权限,并且它将能够根据需要读取和写入。概念有很多不同的集成容易获得,但是我们将与预制模板共同创建自己的组合。
As well, this is mostly a proof of concept. While it may be useful to some in its current state, this article is designed to help you get to grips with the Notion API and build your own integrations.
同样,这主要是概念证明。尽管它对当前状态的某些人可能很有用,但本文旨在帮助您掌握概念API并建立自己的集成。
Setting up API access in Notion
在概念中设置API访问
Notion's API is easy to use
概念的API易于使用
First and foremost, Notion's API is really easy to use and quite well-documented. It can be quite hard to get started if you're not too familiar, so we'll walk you through the steps in order to create your own integration. The pictures above can also be used as a reference to ensure that you are creating the integration correctly.
首先,Intion的API确实易于使用并且有充分的文献记录。如果您不太熟悉,可能很难入门,因此我们会引导您完成这些步骤,以创建自己的集成。上面的图片也可以用作参考,以确保您正确创建集成。
Next, we'll need to create the Notion database that your notes will be stored in. We're going to use the To-do List template on Notion, though we'll need to remove some additional fields. This template turns each task into its own page so that you can enter additional information.
接下来,我们需要创建您的笔记将存储在其中的概念数据库。尽管我们需要删除一些其他字段,但我们将使用概念上的待办事项列表模板。该模板将每个任务变成自己的页面,以便您可以输入其他信息。
Now that we have our template ready, click the "..." button (to the left of "New") and click "Customize To-dos". Click "Tasks" to remove it from the database. This will allow us to modify the fields in the template, where we can remove the "Assign" and "Due" fields. I also renamed "Task name" to simply "Name".
现在,我们已经准备好模板了,请单击“ ...”按钮(在“新”的左侧),然后单击“自定义待办事项”。单击“任务”将其从数据库中删除。这将使我们能够修改模板中的字段,我们可以在其中删除“分配”和“应得的”字段。我还将“任务名称”重命名为“名称”。
Finally, we'll finish by adding our integration to the page, so that it can edit the page. Go to the very top right of the page, where there's another "..." button. Click that, hover over "Connections" and scroll down to the integration that we created. Click it, and confirm that you want to give it access to the page.
最后,我们将通过将集成添加到页面上来结束,以便它可以编辑页面。转到页面右上角,那里还有另一个“ ...”按钮。单击它,悬停在“连接”上,然后向下滚动到我们创建的集成。单击它,并确认您要访问该页面。
Now with our page set up, we can move on to deploying the script to synchronize our Obsidian notes with Notion!
现在,经过我们的页面设置,我们可以继续部署脚本以将我们的黑曜石笔记与概念同步!
Setting up our script
设置我们的脚本
You need your database ID, integration token, and Markdown file name
您需要数据库ID,集成令牌和Markdown文件名
The script that I've written can be found on GitHub, and it's pretty easy to get set up. You'll need to have Python installed on your machine, and you'll need to place the downloaded script in the same folder as your Obsidian notes. The only required Python library that doesn't already come preinstalled is the requests library, which you can install with the following command:
我编写的脚本可以在Github上找到,并且很容易设置。您需要在计算机上安装Python,并且需要将下载的脚本放在与黑曜石笔记同一文件夹中。唯一需要预先安装的唯一必需的python库是请求库,您可以使用以下命令安装:
pip3 install requests
PIP3安装请求
Next, you'll need to replace the NOTION_TOKEN, DATABASE_ID, and TASKS variables defined at the start of the file with your details. The token is the integration token that we created earlier, and the database ID is found in the URL of the Notion database we created. The database ID is everything after "notion.so/" and everything before "?v=..." For example, a database ID might look like the following:
接下来,您需要替换文件开头定义的notion_token,database_id和任务变量,并使用您的详细信息。令牌是我们之前创建的集成令牌,并且数据库ID在我们创建的概念数据库的URL中找到。数据库ID是“ intion.so/”之后的所有内容,并且在“ v = ...之前的所有内容”中,数据库ID可能看起来如下:
1bd1ef8871068079b3f7e7a515dc292b
1BD1EF8871068079B3F7E7A515DC292B
Finally, replace "tasks.md" with the actual name of the markdown file that you use to track your tasks. I used tasks.md to test this script, but if you already have a daily tracker, you can change the name to match the file where they're stored.
最后,将“ tasks.md”替换为您用于跟踪任务的Markdown文件的实际名称。我使用tasks.md来测试此脚本,但是如果您已经有每日跟踪器,则可以更改名称以匹配存储的文件。
Running the script
运行脚本
Now that we have everything in place, we can run the script! Simply open a terminal in the folder and run the following command:
现在我们已经准备好了所有东西,我们可以运行脚本!只需在文件夹中打开终端并运行以下命令:
python3 synctasks.py
Python3 Synctasks.py
This will then connect to your Notion database with your integration token, read your markdown file, and synchronize its contents with the server. You can also automate the running of the script so that it synchronizes multiple times a day. It will remove tasks that you delete from your notes, and it will also update the status if you change them from incomplete to completed (or vice versa).
然后,这将使用您的集成令牌连接到您的概念数据库,读取您的Markdown文件,并将其内容与服务器同步。您也可以自动化脚本的运行,以便每天多次同步。它将删除您从笔记中删除的任务,如果将状态从不完整更改为已完成(或VICE反之亦然),它也将更新状态。
This is a very basic script that will get you started with the Notion API, and you can expand on its functionality to do a lot more than just manage
这是一个非常基本的脚本,可以使您开始使用概念API,并且您可以扩展其功能,而不仅仅是管理
免责声明:info@kdj.com
所提供的信息并非交易建议。根据本文提供的信息进行的任何投资,kdj.com不承担任何责任。加密货币具有高波动性,强烈建议您深入研究后,谨慎投资!
如您认为本网站上使用的内容侵犯了您的版权,请立即联系我们(info@kdj.com),我们将及时删除。
-
- 比特币价格激增触发了大规模的短清算
- 2025-03-25 20:45:12
- 比特币的价格涨幅为87,000美元,引发了一波短暂的清算浪潮,迫使看跌商人亏本关闭头寸。
-
- 尽管ETH价格下跌,以太坊网络市值超过了丰田和白金
- 2025-03-25 20:45:12
- 在持续交易所交易基金(ETF)流出时,Ether(ETH)在撰写本文时以大约2,088美元的价格交易,下降了57%以上
-
-
- 2025年为以太坊涂了一个动荡的画布
- 2025-03-25 20:40:16
- 与看涨的预测相对于以太坊的下降低于2,000美元的阈值
-
- 美国的经济增长从支持它的人们那里缩小。富人正在收紧钱包。
- 2025-03-25 20:35:12
- 这篇博客文章调查了富裕的美国人减少支出对美国经济的影响。
-
-
-
- 出现了令人不安的新趋势:一个复杂的陪审团骗局,将无辜的公民人质绑架并要求比特币付款
- 2025-03-25 20:30:12
- 陪审团的这种比特币欺诈行为通过电话骚扰了许多人,并声称如果他们现在不付款,他们将被捕。
-
- Dogecoin团队宣布与Indy 500团队建立合作伙伴关系,以提高慈善计划
- 2025-03-25 20:25:12
- 预计这种合作伙伴关系将提高Dogecoin的品牌知名度,尤其是在跟随赛车运动的主流观众中。