ehForwarderBot / efb-mp-instantview-middleware

3 stars 5 forks source link

some URL to telegraph, some not, don't know why. #1

Closed QQ-War closed 2 years ago

QQ-War commented 2 years ago

the first one didn't, while the second success. I didn't find the difference.

Tay 07 21:55:03 computer_name ehforwarderbot[157844]: received event: EventGroupMsg Tay 07 21:55:03 computer_name ehforwarderbot[157844]: {'event': 'EventGroupMsg', 'robot_wxid': '删除', 'robot_name': '', 'type': 'share', 'from_wxid': '删除', 'from_name': '删除', 'final_from_wxid': '删除', 'final_from_name': '删除', 'to_wxid': '删除', 'msgid': '1772797919', 'msg': '\r\n \r\n <![CDATA[删除]]>\r\n <![CDATA[删除]]>\r\n \r\n 5\r\n 0\r\n \r\n <![CDATA[删除URL]]>\r\n \r\n \r\n 0\r\n \r\n \r\n\r\n <![CDATA[删除URL]]>\r\n <![CDATA[]]>\r\n <![CDATA[]]>\r\n <![CDATA[0]]>\r\n <![CDATA[]]>\r\n <![CDATA[]]>\r\n <![CDATA[]]>\r\n\r\n \r\n \r\n <![CDATA[]]>\r\n \r\n fromusername><![CDATA[25984984653187515@openim]]\r\n \r\n \r\n \r\n \r\n \r\n \r\n'} Tay 07 21:55:03 computer_name ehforwarderbot[157844]: 2022-04-07 21:55:03,889 [DEBUG]: efb_telegram_master.slave_message (slave_message.send_message; slave_message.py:91) Tay 07 21:55:03 computer_name ehforwarderbot[157844]: [None] Slave message delivered to ETM.

Tay 07 21:59:19 computer_name ehforwarderbot[157844]: {'event': 'EventGroupMsg', 'robot_wxid': '删除', 'robot_name': '', 'type': 'share', 'from_wxid': '删除', 'from_name': '删除', 'final_from_wxid': '删除', 'final_from_name': '删除', 'to_wxid': '删除', 'msgid': '1772797920', 'msg': '\r\n \r\n <![CDATA[删除]]>\r\n <![CDATA[删除]]>\r\n \r\n 5\r\n 0\r\n \r\n <![CDATA[删除URL]]>\r\n \r\n \r\n 0\r\n \r\n \r\n\r\n <![CDATA[删除URL]]>\r\n <![CDATA[]]>\r\n <![CDATA[]]>\r\n <![CDATA[0]]>\r\n <![CDATA[]]>\r\n <![CDATA[]]>\r\n <![CDATA[]]>\r\n\r\n \r\n \r\n <![CDATA[]]>\r\n \r\n fromusername><![CDATA[25984984653187515@openim]]\r\n \r\n \r\n \r\n \r\n \r\n \r\n'} Tay 07 21:59:19 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:19,167 [DEBUG]: urllib3.connectionpool (connectionpool._get_conn; connectionpool.py:266) Tay 07 21:59:19 computer_name ehforwarderbot[157844]: Resetting dropped connection: mp.weixin.qq.com Tay 07 21:59:21 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:21,216 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) Tay 07 21:59:21 computer_name ehforwarderbot[157844]: https://mp.weixin.qq.com:443 "GET /s?t=pages/video_detail_new&scene=1&vid=wxv_2338765966769258496&__biz=MzI0NjA4MzY5OA==&mid=2247502084&idx=3&sn=e51dc6aa941fbdf1e42ec4e0425aba38&vidsn= HTTP/1.1" 200 23072 Tay 07 21:59:21 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:21,240 [DEBUG]: urllib3.connectionpool (connectionpool._new_conn; connectionpool.py:957) Tay 07 21:59:21 computer_name ehforwarderbot[157844]: Starting new HTTPS connection (3): api.telegra.ph:443 Tay 07 21:59:21 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:21,990 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) Tay 07 21:59:21 computer_name ehforwarderbot[157844]: https://api.telegra.ph:443 "POST /createPage HTTP/1.1" 200 243 Tay 07 21:59:21 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:21,992 [DEBUG]: efb_telegram_master.slave_message (slave_message.send_message; slave_message.py:91) Tay 07 21:59:21 computer_name ehforwarderbot[157844]: [None] Slave message delivered to ETM.

QQ-War commented 2 years ago

如下四个链接,第一个链接就稳定不转telegraph。

[3天前,这个小国,狠狠“帮美国教训”了中国和俄罗斯?: http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=1&sn=366826a0aa3a63dfb69a1ec08d6dbde3&chksm=bf3b3e9f884cb78903777eeab58841dfd16a4344276caa9b0b20dd39cfea3fa1b2d6df40e67c#rd]

[“宁可自己遭罪也不想看到它们受伤害”: http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=3&sn=d104846d1fc1602bc1d26183ac836b0c&chksm=bf3b3e9f884cb789949fe700f180e0181768f2eda72a1acd92e01889e7c9fe959ec8d06820ee#rd]

[魔幻现实丨每日一冷: http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=6&sn=924a311436255160975df87ced11a0ea&chksm=bf3b3e9f884cb7897936414871e663a0f10a2a045a6afa8aae93a277b543e627ab851585f7ca#rd]

[上海努力做到蔬菜礼包全覆盖、深圳建立国内首个宠物方舱、少林寺进军房地产丨酷玩日爆: http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=7&sn=7e9388084fd7d3d6eb346f60537724e3&chksm=bf3b3e9f884cb7892d84dcd85691508971b4aefde5f0a466de614b61a672115fd5887157e422#rd]

QQ-War commented 2 years ago

更多日志,可以看到是middleware失败。

Tay 09 09:36:48 computername ehforwarderbot[173558]: {'event': 'EventFriendMsg', ****, 'msg': '<?xml version="1.0"?>\r\n\r\n\t\r\n\t\t3天前,这个小国,狠狠“帮美国教训”了中国和俄罗斯?\r\n\t\t美国“代言人”立陶宛:叫唤得有多凶,脸打得就有多疼\r\n\t\t\r\n\t\tview\r\n\t\t5\r\n\t\t0\r\n\t\t\r\n\t\thttp://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&amp;mid=2650229747&amp;idx=1&amp;sn=366826a0aa3a63dfb69a1ec08d6dbde3&amp;chksm=bf3b3e9f884cb78903777eeab58841dfd16a4344276caa9b0b20dd39cfea3fa1b2d6df40e67c#rd\r\n\t\t\r\n\t\t0\r\n\t\t\r\n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t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[0]]>\r\n\t\t\t<![CDATA[0]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t<![CDATA[]]>\r\n\t\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t<![CDATA[]]>\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t0\r\n\t\t\t\r\n\t\t\r\n\t\t\r\n\t\t\t<![CDATA[0]]>\r\n\t\t\r\n\t\t0\r\n\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t0\r\n\t\t\t\r\n\t\t\r\n\t\t\r\n\t\t\t0\r\n\t\t\r\n\t\t\r\n\t\t\t0\r\n\t\t\t0\r\n\t\t\r\n\t\r\n\twxid_8u55pl2uvpny22\r\n\t0\r\n\t\r\n\t\t1\r\n\t\t\r\n\t\r\n\t\r\n\r\n'} Tay 09 09:36:48 computer_name ehforwarderbot[173558]: 2022-04-09 09:36:48,480 [DEBUG]: urllib3.connectionpool (connectionpool._get_conn; connectionpool.py:266) Tay 09 09:36:48 computer_name ehforwarderbot[173558]: Resetting dropped connection: mp.weixin.qq.com Tay 09 09:36:49 computer_name ehforwarderbot[173558]: 2022-04-09 09:36:49,174 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) Tay 09 09:36:49 computer_name ehforwarderbot[173558]: http://mp.weixin.qq.com:80 "GET /s?biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=1&sn=366826a0aa3a63dfb69a1ec08d6dbde3&chksm=bf3b3e9f884cb78903777eeab58841dfd16a4344276caa9b0b20dd39cfea3fa1b2d6df40e67c HTTP/1.1" 301 962 Tay 09 09:36:49 computer_name ehforwarderbot[173558]: 2022-04-09 09:36:49,179 [DEBUG]: urllib3.connectionpool (connectionpool._get_conn; connectionpool.py:266) Tay 09 09:36:49 computer_name ehforwarderbot[173558]: Resetting dropped connection: mp.weixin.qq.com Tay 09 09:36:50 computer_name ehforwarderbot[173558]: 2022-04-09 09:36:50,943 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) Tay 09 09:36:50 computer_name ehforwarderbot[173558]: https://mp.weixin.qq.com:443 "GET /s?biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=1&sn=366826a0aa3a63dfb69a1ec08d6dbde3&chksm=bf3b3e9f884cb78903777eeab58841dfd16a4344276caa9b0b20dd39cfea3fa1b2d6df40e67c HTTP/1.1" 200 57726 Tay 09 09:36:54 computer_name ehforwarderbot[173558]: 2022-04-09 09:36:54,263 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) Tay 09 09:36:54 computer_name ehforwarderbot[173558]: https://api.telegra.ph:443 "POST /createPage HTTP/1.1" 200 58 Tay 09 09:36:54 computer_name ehforwarderbot[173558]: 2022-04-09 09:36:54,264 [DEBUG]: plugins.catbaron.mp_instantview.MPInstantViewMiddleware (init.process_url; init.py:95) Tay 09 09:36:54 computer_name ehforwarderbot[173558]: Failed to process mp url! Tay 09 09:36:54 computer_name ehforwarderbot[173558]: 2022-04-09 09:36:54,264 [DEBUG]: plugins.catbaron.mp_instantview.MPInstantViewMiddleware (init.process_url; init.py:96) Tay 09 09:36:54 computer_name ehforwarderbot[173558]: 'result' Tay 09 09:36:54 computer_name ehforwarderbot[173558]: 2022-04-09 09:36:54,265 [DEBUG]: efb_telegram_master.slave_message (slave_message.send_message; slave_message.py:91)

Rongronggg9 commented 2 years ago
Tay 09 09:36:54 computer_name ehforwarderbot[173558]: [https://api.telegra.ph:443](https://api.telegra.ph/) "POST /createPage HTTP/1.1" 200 58

58 表示 Telegraph API 返回的消息长度,这么短的长度,很明显是返回了一个错误,至于是啥,我猜是内容长度超限。

QQ-War commented 2 years ago

自己跑了一下, 最后print有点问题,回来再看看具体原因吧。

page = tg.process_url('http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&amp;mid=2650229747&amp;idx=1&amp;sn=366826a0aa3a63dfb69a1ec08d6dbde3&amp;chksm=bf3b3e9f884cb78903777eeab58841dfd16a4344276caa9b0b20dd39cfea3fa1b2d6df40e67c#rd') (这里没有问题) print(tg.publish(page['title'], page['author'], page['content'])) Traceback (most recent call last): File "", line 1, in File "/home/pcloud/.local/lib/python3.8/site-packages/efb_mp_instantview_middleware/telegraph.py", line 59, in publish return response['result']['url'] KeyError: 'result'

Rongronggg9 commented 2 years ago

没有 result 就是 Telegraph API 不能成功生成文章,所以不会返回 result ,通常原因就是文章太长,超过 64KB

QQ-War commented 2 years ago

修改了下publich,直接返回respones,确实是太大了。这个有办法解决吗?

print(tg.publish) <bound method Telegraph.publish of <debug_QQ_war.Telegraph object at 0x7fef7e0d55b0>> print(tg.publish(page['title'], page['author'], page['content'])) {'ok': False, 'error': 'CONTENT_TOO_BIG'}

Rongronggg9 commented 2 years ago

没有办法,这是硬性限制

QQ-War commented 2 years ago

写了个修改判断大小,如果超过65536就删除attrs属性的补丁。

QQ-War commented 2 years ago

还是没啥用,有的文章过于长,估计只能从把一篇分拆成几篇入手来考虑设计。但是Json要分拆真的好难。

catbaron0 commented 2 years ago

see https://github.com/ehForwarderBot/efb-mp-instantview-middleware/pull/2