市值: $2.8611T -0.270%
體積(24小時): $79.8495B 13.390%
  • 市值: $2.8611T -0.270%
  • 體積(24小時): $79.8495B 13.390%
  • 恐懼與貪婪指數:
  • 市值: $2.8611T -0.270%
加密
主題
加密植物
資訊
加密術
影片
頭號新聞
加密
主題
加密植物
資訊
加密術
影片
bitcoin
bitcoin

$86704.569562 USD

0.44%

ethereum
ethereum

$2054.519007 USD

2.14%

tether
tether

$1.000198 USD

0.01%

xrp
xrp

$2.421278 USD

-0.81%

bnb
bnb

$638.988699 USD

2.50%

solana
solana

$139.305622 USD

1.55%

usd-coin
usd-coin

$1.000003 USD

-0.02%

dogecoin
dogecoin

$0.184621 USD

6.26%

cardano
cardano

$0.727769 USD

1.88%

tron
tron

$0.226526 USD

-0.08%

chainlink
chainlink

$15.029314 USD

2.90%

toncoin
toncoin

$3.658590 USD

0.34%

unus-sed-leo
unus-sed-leo

$9.776464 USD

0.08%

stellar
stellar

$0.288665 USD

2.25%

avalanche
avalanche

$21.396133 USD

1.98%

加密貨幣新聞文章

同步我的待辦事項清單從黑曜石到概念數據庫

2025/03/23 10:14

我已經開始大量使用黑曜石,因為這是一個很棒的筆記實用程序,並具有許多高級功能,插件和社區支持。

同步我的待辦事項清單從黑曜石到概念數據庫

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日 其他文章發表於