forked from malinkang/weread2notion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
122 lines (98 loc) · 2.71 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
def get_heading(level, content):
if level == 1:
heading = "heading_1"
elif level == 2:
heading = "heading_2"
else:
heading = "heading_3"
return {
"type": heading,
heading: {
"rich_text": [
{
"type": "text",
"text": {
"content": content,
},
}
],
"color": "default",
"is_toggleable": False,
},
}
def get_table_of_contents():
"""获取目录"""
return {"type": "table_of_contents", "table_of_contents": {"color": "default"}}
def get_title(content):
return {"title": [{"type": "text", "text": {"content": content}}]}
def get_rich_text(content):
return {"rich_text": [{"type": "text", "text": {"content": content}}]}
def get_url(url):
return {"url": url}
def get_file(url):
return {"files": [{"type": "external", "name": "Cover", "external": {"url": url}}]}
def get_multi_select(names):
return {"multi_select": [{"name": name} for name in names]}
def get_date(start):
return {
"date": {
"start": start,
"time_zone": "Asia/Shanghai",
}
}
def get_icon(url):
return {"type": "external", "external": {"url": url}}
def get_select(name):
return {"select": {"name": name}}
def get_number(number):
return {"number": number}
def get_quote(content):
return {
"type": "quote",
"quote": {
"rich_text": [
{
"type": "text",
"text": {"content": content},
}
],
"color": "default",
},
}
def get_callout(content, style, colorStyle, reviewId):
# 根据不同的划线样式设置不同的emoji 直线type=0 背景颜色是1 波浪线是2
emoji = "〰️"
if style == 0:
emoji = "💡"
elif style == 1:
emoji = "⭐"
# 如果reviewId不是空说明是笔记
if reviewId != None:
emoji = "✍️"
color = "default"
# 根据划线颜色设置文字的颜色
if colorStyle == 1:
color = "red"
elif colorStyle == 2:
color = "purple"
elif colorStyle == 3:
color = "blue"
elif colorStyle == 4:
color = "green"
elif colorStyle == 5:
color = "yellow"
return {
"type": "callout",
"callout": {
"rich_text": [
{
"type": "text",
"text": {
"content": content,
},
}
],
"icon": {"emoji": emoji},
"color": color,
},
}