diff --git a/.github/workflows/weread.yml b/.github/workflows/weread.yml index 040515f3197..ce0fd7c6d6d 100644 --- a/.github/workflows/weread.yml +++ b/.github/workflows/weread.yml @@ -22,7 +22,7 @@ jobs: pip install -r requirements.txt - name: weread sync run: | - python weread.py "${{secrets.WEREAD_COOKIE}}" "${{secrets.NOTION_TOKEN}}" "${{secrets.NOTION_DATABASE_ID}}" "${{ github.ref }}" "${{ github.repository }}" + python weread.py "${{secrets.WEREAD_COOKIE}}" "${{secrets.NOTION_TOKEN}}" "${{secrets.NOTION_DATABASE_ID}}" "${{ github.ref }}" "${{ github.repository }}" --styles 0 1 2 --colors 1 2 3 4 5 - name: Push Cover run: | git config --local user.email "action@github.com" diff --git a/cover/CB_9ax3Gh3GK5B46i26g289e0DH_parsecover.jpg b/cover/CB_9ax3Gh3GK5B46i26g289e0DH_parsecover.jpg new file mode 100644 index 00000000000..9022a591ce5 Binary files /dev/null and b/cover/CB_9ax3Gh3GK5B46i26g289e0DH_parsecover.jpg differ diff --git a/weread.py b/weread.py index 8086ebcb285..0a62d6afc39 100644 --- a/weread.py +++ b/weread.py @@ -132,7 +132,7 @@ def get_quote(content): def get_callout(content, style, colorStyle, reviewId): # 根据不同的划线样式设置不同的emoji 直线type=0 背景颜色是1 波浪线是2 - emoji = "🌟" + emoji = "〰️" if style == 0: emoji = "💡" elif style == 1: @@ -324,6 +324,11 @@ def get_children(chapter, summary, bookmark_list): children.append(get_heading( chapter.get(key).get("level"), chapter.get(key).get("title"))) for i in value: + if(i.get("reviewId")==None): + if(i.get("style") not in styles): + continue + if(i.get("colorStyle") not in colors): + continue markText = i.get("markText") for j in range(0, len(markText)//2000+1): children.append(get_callout(markText[j*2000:(j+1)*2000],i.get("style"), i.get("colorStyle"), i.get("reviewId"))) @@ -334,9 +339,14 @@ def get_children(chapter, summary, bookmark_list): else: # 如果没有章节信息 for data in bookmark_list: + if(data.get("reviewId")==None): + if(data.get("style") not in styles): + continue + if(data.get("colorStyle") not in colors): + continue markText = data.get("markText") for i in range(0, len(markText)//2000+1): - children.append(get_callout(markText[i*200:(i+1)*2000], + children.append(get_callout(markText[i*2000:(i+1)*2000], data.get("style"), data.get("colorStyle"), data.get("reviewId"))) if summary != None and len(summary) > 0: children.append(get_heading(1, "点评")) @@ -418,6 +428,8 @@ def download_image(url, save_dir='cover'): parser.add_argument("database_id") parser.add_argument("ref") parser.add_argument("repository") + parser.add_argument("--styles",nargs="+",type=int,help="划线样式") + parser.add_argument("--colors",nargs="+",type=int,help="划线颜色") options = parser.parse_args() weread_cookie = options.weread_cookie database_id = options.database_id @@ -425,7 +437,8 @@ def download_image(url, save_dir='cover'): ref = options.ref branch = ref.split('/')[-1] repository = options.repository - print(f"ref = {ref}, repository = {repository}") + styles = options.styles + colors = options.colors session = requests.Session() session.cookies = parse_cookie_string(weread_cookie) client = Client(