For some reason whenever I create a new task with specified tags, the tags aren't saved into Notion.
Here's the code I'm using. It tasks a string such as "this is the name of the task #tag !high" and correctly parses that it has the tags ["tag"], a priority of ["high"], and a name of "this is the name of the task". However, while Notion is saving the priority and name, but not the tags. Am I doing anything wrong? From what I can tell by reading the docs, this should work.
I've tested this with tags that are already defined in Notion.
import argparse
import sys
from notion.client import NotionClient
parser = argparse.ArgumentParser()
parser.add_argument("query")
args = parser.parse_args()
query = args.query
if(query != ''):
def extract_meta_data(splitQuery, keyString, options=[]):
final_list = list(set(part[len(keyString):] for part in splitQuery if (part.startswith(keyString) and (len(options) == 0 or (part[len(keyString):] in options)))))
for item in final_list:
splitQuery.remove(keyString + item)
return final_list
def get_first_item(array):
if len(array) != 0:
return array[0]
return
client = NotionClient(token_v2="<token>")
cv = client.get_collection_view("<collection URL>")
splitQuery = query.split()
tags = extract_meta_data(splitQuery, '#')
priority = get_first_item(extract_meta_data(splitQuery, '!', ['urgent', 'high', 'medium', 'low']))
row = cv.collection.add_row()
row.name = ' '.join(splitQuery)
row.tags = tags
row.priority = priority
This script is run with this command and args
python3 main.py "this is the name of the task #tag !high"
For some reason whenever I create a new task with specified tags, the tags aren't saved into Notion.
Here's the code I'm using. It tasks a string such as
"this is the name of the task #tag !high"
and correctly parses that it has the tags["tag"]
, a priority of["high"]
, and a name of"this is the name of the task"
. However, while Notion is saving the priority and name, but not the tags. Am I doing anything wrong? From what I can tell by reading the docs, this should work.I've tested this with tags that are already defined in Notion.
This script is run with this command and args
This is the full source code.