| 1234567891011121314151617181920212223242526272829 |
- from notion_client import Client
-
- # --- CONFIG ---
- NOTION_TOKEN = "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"
- TODO_PREFIX = "To do du projet @"
- notion = Client(auth=NOTION_TOKEN)
-
-
- # --- Extraction des tâches ---
- def extract_tasks(database_id):
- tasks = []
- cursor = None
- while True:
- res = notion.databases.query(database_id=database_id, start_cursor=cursor)
- for row in res["results"]:
- props = row["properties"]
- name_data = props.get("Tache", {}).get("title", [])
- name = name_data[0]["plain_text"] if name_data else ""
- status = props.get("Status", {}).get("status", {})
- status_name = status.get("name", "") if status else ""
- date_field = props.get("Dead line", {}).get("date")
- deadline = date_field.get("start") if date_field else ""
- person = [p.get("name") for p in props.get("person", {}).get("people", [])]
- url = f"https://www.notion.so/{row['id'].replace('-', '')}"
- tasks.append((name, status_name, deadline, ", ".join(person), url))
- if not res.get("has_more"):
- break
- cursor = res["next_cursor"]
- return tasks
|