malinkang / weread2notion Goto Github PK
View Code? Open in Web Editor NEW将微信读书划线同步到Notion
Home Page: https://book.malinkang.com
将微信读书划线同步到Notion
Home Page: https://book.malinkang.com
第一次发生时我直接删了原来的,重新建了一个,但是后来建的第二个还是发生这种情况,于是我将Cookie和NotionDatabaseID给替换了,然后我手动运行了一次,成功了,请问如何避免下次遇到这种情况?
报错代码如下,谢谢
Traceback (most recent call last):
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 409, in
isbn,rating = get_bookinfo(bookId)
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 67, in get_bookinfo
return (isbn, newRating)
UnboundLocalError: local variable 'newRating' referenced before assignment
Error: Process completed with exit code 1.
第一次成功运行action,只同步成功了3本书。有两本是今天读,一本是昨天读的。但是更早之前的笔记就没有更新了。
其他的书都还是复制过来的模版中的读书笔记,不是我自己的。
现在笔记条数是124,同步之前是121。
看了action的日子,同步已经运行结束正确退出了。
具体问题是:
Traceback (most recent call last):
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 389, in <module>
session.get(WEREAD_URL)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/requests/sessions.py", line 719, in send
extract_cookies_to_jar(self.cookies, request, r.raw)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/requests/cookies.py", line [13](https://github.com/Xiaoshizi1024/weread_to_notion/actions/runs/6439335875/job/17489578613#step:5:14)7, in extract_cookies_to_jar
jar.extract_cookies(res, req)
AttributeError: 'NoneType' object has no attribute 'extract_cookies'
Error: Process completed with exit code 1.
没有对代码做任何改变,那么能错误的只有上传的三个参数,看着应该是cookie的问题。
自我测试,用edge获取的cookie跟Google Chrome获取的格式竟然都不一样,两个都测试了,但是还是出现同样的错误。
那么难道是我获取的cookie有问题?
我是如何获取cookie的?
我具体上传参数格式是这样的
Sync报如下错误
Run python weread.py "" "" "***"
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/notion_client/client.py", line 118, in _parse_response
response.raise_for_status()
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/httpx/_models.py", line 758, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.notion.com/v1/databases/***/query'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400
看起来是Secrets没有获取到?但在fork的代码中按照guide添加了3个token的。
手动跑了一次workflow,显示运行成功了,logs里面确实也能看到记录,但是notion的page里还是空的,请问有什么可能的原因么
Traceback (most recent call last):
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 409, in <module>
isbn,rating = get_bookinfo(bookId)
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 67, in get_bookinfo
return (isbn, rating)
UnboundLocalError: local variable 'rating' referenced before assignment
Error: Process completed with exit code 1.
报错如上,google 了一下,意思是在函数内部更改全局变量导致的错误,需要在函数内部做个声明 global rating
,不知是否可行。
但在 notion 有记录且仅有一条。
如果大佬更新了代码,我们需要重新 fork ,重新走流程吗?
感谢!
我发现,需要微信读书上有自己的划线或者笔记才可以同步,请问能否实现不需要划线和笔记,只要在书架的书就可以同步呢?
问题:
notion_client.errors.APIResponseError: ISBN is not a property that exists. URL is not a property that exists. Rating is not a property that exists.
原因:
拥有老模版的用户,因为缺少新增的:ISBN URL Rating 三个字段,
解决方案:
需要自己手工该模版添加属性,或者删除模版重新导入模版重新同步。
github->我fork的项目->settings->Secrets and variables中有actions, codespaces, dependabot三个选项,是在哪一个里进行new repository secret呢
notion_client.errors.APIResponseError: ISBN is not a property that exists. URL is not a property that exists. Rating is not a property that exists.
模板缺少这三个新加的property(ISBN, URL, Rating), 需要加到Table properties
教程里缺少notion database - add connection 这个部分, 不做的话 notion token access 不了database
已经根据步骤正确设置了NOTION_TOKEN、NOTION_DATABASE_ID、WEREAD_COOKIE,但在运行时出现如下报错:
Traceback (most recent call last):
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 345, in
session.get(WEREAD_URL)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/sessions.py", line 719, in send
extract_cookies_to_jar(self.cookies, request, r.raw)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/cookies.py", line 137, in extract_cookies_to_jar
jar.extract_cookies(res, req)
AttributeError: 'NoneType' object has no attribute 'extract_cookies'
Error: Process completed with exit code 1.
看上去似乎是因为Cookie传参有问题?
Run python weread.py "" "" "***"
Traceback (most recent call last):
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 389, in
session.get(WEREAD_URL)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/sessions.py", line 717, in send
extract_cookies_to_jar(self.cookies, request, r.raw)
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/requests/cookies.py", line 137, in extract_cookies_to_jar
jar.extract_cookies(res, req)
AttributeError: 'NoneType' object has no attribute 'extract_cookies'
Error: Process completed with exit code 1.
我的手动执行都好使,为啥自动执行无效,每天0点不执行,改成0/5 * * * *,每5分钟执行一次也是无效,是否还有啥地方配置自动执行的操作。
希望不仅可以有划线,还能同步笔记
错误信息:
Traceback (most recent call last):
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 380, in
bookmark_list = sorted(bookmark_list, key=lambda x: (
File "/home/runner/work/weread_to_notion/weread_to_notion/weread.py", line 381, in
x.get("chapterUid", 1), 0 if x.get("range") == "" else int(x.get("range").split("-")[0])))
AttributeError: 'NoneType' object has no attribute 'split'
例如原来有三条笔记,删了一条,同步后能否在notion也去掉删除的划线?
报错:
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/notion_client/client.py", line 118, in _parse_response
response.raise_for_status()
File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/httpx/_models.py", line 749, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '404 Not Found' for url 'https://api.notion.com/v1/databases/***/query'
For more information check: https://httpstatuses.com/404
notion_client.errors.APIResponseError: Could not find database with ID: *my_id. Make sure the relevant pages and databases are shared with your integration.
无法同步,报错如标题
notion_client.errors.APIResponseError: Could not find database with ID: bcc5b817-f4e2-4086-848a-b9d69333329d. Make sure the relevant pages and databases are shared with your integration.
反复确认,这个database id 是存在的。所以不知道哪里错了。
微信群名片过期了,能更新一下吗
book.malinkang.com 这个是NOtion付费版 ,高的域名吗
除了第一天成功同步之外,之后connection就完全没有修改过database。不知道是否跟cookie一直在变有关——因为我开了禁广告ADguard。
但是当我把Adguard关掉,更新cookie以后手动同步,页面还是没有变化。我确定token和dataID都是正确的
自己上传到微信读书里的mobi和epub格式受影响,pdf格式的书籍的cover封面显示正常,不受影响。
notion里,其余字段正常获取不受影响,并且bookname前面的图标显示正常,有数据的封面,但cover里为cover的灰色链接:https://wrco-40036.sh.gfp.tencent-cloud.com/CB_EMb3Zh3YK8uJ6i36gwBfz3hn/parsecover?sign=q-sign-algorithm%3Dsha1%26q-ak%3Dcydn1szJ2OQT2J72AOTKL4DZ%26q-sign-time%3D1692166441%3B1692167041%26q-key-time%3D1692166441%3B1692167041%26q-header-list%3Dhost%26q-url-param-list%3D%26q-signature%3D8ac25232101ff8260068cd4e5c79855740080787
于是乎来到weread.qq.com检查,发现mobi和epub的封面链接均为下载文件的形式,pdf则为图片形式。
私以为说明程序是正常跑的,链接也抓到了,只是notion数据里的cover字段是文件和媒体公用字段,链接被notion识别为了文件,故而没有使用图片进行直接展示,至于微信读书里mobi和epub的图片链接为文件格式,可能是有特殊原因存在。
不知道可不可行的胡乱猜想不负责任信口胡说解决方案:
1、微信读书侧生成的链接有没有可能转换为图片形式;
2、notion里关于cvoer字段能否像bookname前面的图标一样直接显示为图片;
3、py检测到链接里包含:parsecover时,下载图片转存到notion,在notion进行显示。
从重构版本更新那天起就一直报同样的错误:
`Run github_heatmap weread --weread_cookie "***" --year 2018-2023 --me "" --with-animation --background-color=#ffffff --track-color=#ACE7AE --special-color1=#69C16E --special-color2=#549F57 --dom-color=#EBEDF0 --text-color=#000000
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.18/x64/bin/github_heatmap", line 8, in
sys.exit(main())
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/github_heatmap/cli.py",
line 182, in main
run()
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/github_heatmap/cli.py",
line 89, in run
tracks, years = loader.get_all_track_data()
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/github_heatmap/loader/weread_loader.py", line 50, in get_all_track_data
self.make_track_dict()
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/github_heatmap/loader/weread_loader.py", line 41, in make_track_dict
readTimes = dict(sorted(api_data["readTimes"].items(), reverse=True))
KeyError: 'readTimes'
Error: Process completed with exit code 1.`
刚开始以为是notion模板的问题,把模板删除了重新复制了,更新了database_id,还是报错。
Traceback (most recent call last):
File "/home/runner/work/munotion/munotion/weread.py", line 404, in
bookmark_list = get_bookmark_list(bookId)
File "/home/runner/work/munotion/munotion/weread.py", line 43, in get_bookmark_list
updated = sorted(updated, key=lambda x: (
File "/home/runner/work/munotion/munotion/weread.py", line 44, in
x.get("chapterUid", 1), int(x.get("range").split("-")[0])))
ValueError: invalid literal for int() with base 10: ''
您好,每一步否按照要求做了,但是无法实现相应的功能。是否因为现在有了新的变化?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.