Skip to content

Commit 759db3a

Browse files
authored
Merge branch 'malinkang:main' into main
2 parents 0ab8d0b + 631ae91 commit 759db3a

10 files changed

+626
-516
lines changed

.github/workflows/weread.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ jobs:
88
sync:
99
name: Sync
1010
runs-on: ubuntu-latest
11+
env:
12+
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
13+
NOTION_PAGE: ${{ secrets.NOTION_PAGE }}
14+
NOTION_DATABASE_ID: ${{ secrets.NOTION_DATABASE_ID }}
15+
WEREAD_COOKIE: ${{ secrets.WEREAD_COOKIE }}
16+
CC_URL: ${{ secrets.CC_URL }}
17+
CC_ID: ${{ secrets.CC_ID }}
18+
CC_PASSWORD: ${{ secrets.CC_PASSWORD }}
19+
YEAR: ${{ vars.YEAR }}
1120
steps:
1221
- name: Checkout
1322
uses: actions/checkout@v3
14-
1523
- name: Set up Python
1624
uses: actions/setup-python@v4
1725
with:
@@ -22,11 +30,17 @@ jobs:
2230
pip install -r requirements.txt
2331
- name: weread sync
2432
run: |
25-
python weread.py "${{secrets.WEREAD_COOKIE}}" "${{secrets.NOTION_TOKEN}}" "${{secrets.NOTION_DATABASE_ID}}" "${{ github.ref }}" "${{ github.repository }}" --styles 0 1 2 --colors 0 1 2 3 4 5
26-
- name: Push Cover
33+
python scripts/weread.py
34+
- name: Set default year if not provided
35+
run: echo "YEAR=$(date +"%Y")" >> $GITHUB_ENV
36+
if: env.YEAR == ''
37+
- name: weread heatmap
38+
run: |
39+
github_heatmap weread --year $YEAR --me "${{secrets.NAME}}" --with-animation --background-color=${{ vars.background_color||'#FFFFFF'}} --track-color=${{ vars.track_color||'#ACE7AE'}} --special-color1=${{ vars.special_color||'#69C16E'}} --special-color2=${{ vars.special_color2||'#549F57'}} --dom-color=${{ vars.dom_color||'#EBEDF0'}} --text-color=${{ vars.text_color||'#000000'}}
40+
- name: push
2741
run: |
2842
git config --local user.email "action@github.com"
2943
git config --local user.name "GitHub Action"
3044
git add .
3145
git commit -m 'add new cover' || echo "nothing to commit"
32-
git push || echo "nothing to push"
46+
git push || echo "nothing to push"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
scripts/__pycache__/
2+
.env

OUT_FOLDER/weread.svg

Lines changed: 2 additions & 0 deletions
Loading

README.md

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,28 @@
1111

1212
## 使用
1313

14-
使用文档:https://malinkang.com/posts/weread2notion/
14+
> [!IMPORTANT]
15+
> 关注公众号获取教程
1516
16-
## 捐赠
17+
![扫码_搜索联合传播样式-标准色版](https://github.com/malinkang/weread2notion/assets/3365208/191900c6-958e-4f9b-908d-a40a54889b5e)
1718

18-
如果你觉得本项目帮助了你,请作者喝一杯咖啡,你的支持是作者最大的动力。本项目会持续更新。
1919

20-
![](./asset/WechatIMG27.jpg)
20+
##
21+
> [!IMPORTANT]
22+
> 欢迎加入群讨论。可以讨论使用中遇到的任何问题,也可以讨论Notion使用,后续我也会在群中分享更多Notion自动化工具。微信群失效的话可以添加我的微信malinkang,我拉你入群。
2123
22-
## 问题解答
2324

24-
1. 如果发现数据没有同步,请点击Action查看运行状态。红色表示失败,绿色代表成功,如果有失败的点击去查看详情,检查值是否填写正确
25-
2. Categories is expected to be select. 这个是模板设置的问题,将模板中的Categories修改为Multi-select类型
26-
3. 模板中的属性解释
27-
* BookName:书名
28-
* BookId:书Id
29-
* Sort:主要用于增量同步没啥实际意义
30-
* Cover:封面
31-
* Author:作者
32-
* Status:状态
33-
* ReadingTime:阅读时长
34-
* Date:读完日期
35-
* Rating:评分
36-
* URL:网页链接
37-
* Categories:分类
38-
* Progress:阅读进度
25+
| 微信群 | QQ群 |
26+
| --- | --- |
27+
| <div align="center"><img src="https://images.malinkang.com/2024/04/d54cd68602ccbb9e2747ce01f02280a3.jpg" width="50%"></div> | <div align="center"><img src="https://images.malinkang.com/2024/04/b225b17d60670e4a6ff3459bbde80d28.jpg" width="50%"></div> |
3928

4029

41-
## 微信群
42-
> [!WARNING]
43-
> 微信群已满,加我备注微信读书,我拉你进群。
44-
> 也可以加TG群:https://t.me/wereadnotion
30+
## 捐赠
31+
32+
如果你觉得本项目帮助了你,请作者喝一杯咖啡,你的支持是作者最大的动力。本项目会持续更新。
4533

46-
![image](./asset/WechatIMG24.jpg)
34+
| 支付宝支付 | 微信支付 |
35+
| --- | --- |
36+
| <div align="center"><img src="https://images.malinkang.com/2024/03/7fd0feb1145f19fab3821ff1d4631f85.jpg" width="50%"></div> | <div align="center"><img src="https://images.malinkang.com/2024/03/d34f577490a32d4440c8a22f57af41da.jpg" width="50%"></div> |
4737

4838

-263 KB
Binary file not shown.
-254 KB
Binary file not shown.

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
requests
2-
notion-client
2+
notion-client
3+
github-heatmap
4+
python-dotenv

scripts/utils.py

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

0 commit comments

Comments
 (0)