tianyunperfect 3 سال پیش
والد
کامیت
2728739d62
4فایلهای تغییر یافته به همراه88 افزوده شده و 14 حذف شده
  1. 3 14
      tmp.py
  2. 24 0
      tmp/notion/create_diary.py
  3. 28 0
      tmp/notion/create_dream.py
  4. 33 0
      tmp/notion/notion_get_page.py

+ 3 - 14
tmp.py

@@ -1,15 +1,4 @@
-import base64
+import datetime
+import time
 
-
-def get_bucket_value(id_str: str):
-    base64_value = base64.b64encode(id_str.encode("UTF-8"))
-    hash_value = abs(hash(base64_value))
-    return hash_value % 100
-
-
-print(get_bucket_value("1"))
-# print(get_bucket_value("2"))
-# print(get_bucket_value("3"))
-# print(get_bucket_value("4"))
-# print(get_bucket_value("5"))
-# print(get_bucket_value("6"))
+print(time.strftime("%Y-%m-%d", time.localtime()))

+ 24 - 0
tmp/notion/create_diary.py

@@ -0,0 +1,24 @@
+import time
+
+import requests
+
+url = "https://api.notion.com/v1/pages"
+date_str = time.strftime("%Y-%m-%d", time.localtime())
+payload = {
+    "parent": {"type": "database_id",
+               "database_id": "c246a1a4e4f24ac6ae98c11c0c1c32a9"},
+    "properties": {'日期': {'id': 'qSdW', 'type': 'date',
+                          'date': {'start': date_str, 'end': None, 'time_zone': None}},
+                   'Name': {'id': 'title', 'type': 'title', 'title': [
+                       {'type': 'text', 'text': {'content': date_str, 'link': None}}]}}
+}
+headers = {
+    "Accept": "application/json",
+    "Notion-Version": "2022-02-22",
+    "Content-Type": "application/json",
+    "Authorization": "Bearer secret_PvJWhkqlZJ7PMIqqPxWDhS736TjvUbkGojyrybjyxNh"
+}
+
+response = requests.post(url, json=payload, headers=headers)
+
+print(response.text)

+ 28 - 0
tmp/notion/create_dream.py

@@ -0,0 +1,28 @@
+import time
+
+import requests
+
+url = "https://api.notion.com/v1/pages"
+date_str = time.strftime("%Y-%m-%d", time.localtime())
+payload = {
+    "parent": {"type": "database_id",
+               "database_id": "de2ddb5d286e4dffacb1eb26a4e074be"},
+    "properties": {'类型': {'id': '%3BpWm', 'type': 'select',
+                          'select': {'id': '6bb27fbf-4938-484f-b531-4b10ff5cb718', 'name': '普通梦', 'color': 'orange'}},
+                   '方法': {'id': 'BE%7CY', 'type': 'select', 'select': {
+                       'id': 'e53f9bb4-eb4c-4dfd-b7bf-72fdb01edb14', 'name': '无', 'color': 'red'}},
+                   '时间': {'id': 'qSdW', 'type': 'date',
+                          'date': {'start': date_str, 'end': None, 'time_zone': None}},
+                   'Name': {'id': 'title', 'type': 'title', 'title': [
+                       {'type': 'text', 'text': {'content': date_str, 'link': None}}]}}
+}
+headers = {
+    "Accept": "application/json",
+    "Notion-Version": "2022-02-22",
+    "Content-Type": "application/json",
+    "Authorization": "Bearer secret_PvJWhkqlZJ7PMIqqPxWDhS736TjvUbkGojyrybjyxNh"
+}
+
+response = requests.post(url, json=payload, headers=headers)
+
+print(response.text)

+ 33 - 0
tmp/notion/notion_get_page.py

@@ -0,0 +1,33 @@
+import json
+
+import requests
+
+url = "https://api.notion.com/v1/pages/659d6b28ea6e44a98ef9135f27125213"
+
+headers = {
+    "Accept": "application/json",
+    "Notion-Version": "2022-02-22",
+    "Content-Type": "application/json",
+    "Authorization": "Bearer secret_PvJWhkqlZJ7PMIqqPxWDhS736TjvUbkGojyrybjyxNh"
+}
+
+response = requests.get(url, headers=headers)
+
+print(response.json())
+
+res = {'object': 'page', 'id': '659d6b28-ea6e-44a9-8ef9-135f27125213', 'created_time': '2022-06-17T04:46:00.000Z',
+       'last_edited_time': '2022-06-17T04:46:00.000Z',
+       'created_by': {'object': 'user', 'id': 'bbc16ebc-12d0-48d7-92a8-b8c2b41b43e2'},
+       'last_edited_by': {'object': 'user', 'id': 'bbc16ebc-12d0-48d7-92a8-b8c2b41b43e2'}, 'cover': None, 'icon': None,
+       'parent': {'type': 'database_id', 'database_id': 'de2ddb5d-286e-4dff-acb1-eb26a4e074be'}, 'archived': False,
+       'properties': {'类型': {'id': '%3BpWm', 'type': 'select',
+                             'select': {'id': '6bb27fbf-4938-484f-b531-4b10ff5cb718', 'name': '普通梦',
+                                        'color': 'orange'}}, '方法': {'id': 'BE%7CY', 'type': 'select', 'select': {
+           'id': 'e53f9bb4-eb4c-4dfd-b7bf-72fdb01edb14', 'name': '无', 'color': 'red'}},
+                      '时间': {'id': 'qSdW', 'type': 'date',
+                             'date': {'start': '2022-06-17', 'end': None, 'time_zone': None}},
+                      'Name': {'id': 'title', 'type': 'title', 'title': [
+                          {'type': 'text', 'text': {'content': '巨大的坐骑', 'link': None},
+                           'annotations': {'bold': False, 'italic': False, 'strikethrough': False, 'underline': False,
+                                           'code': False, 'color': 'default'}, 'plain_text': '巨大的坐骑', 'href': None}]}},
+       'url': 'https://www.notion.so/659d6b28ea6e44a98ef9135f27125213'}