Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

最后一页请求不到: [WARN] [get_posts] 'NoneType' object has no attribute 'group'. args=(2428664072, 6) kwargs={'rn': 30, 'with_comments': True} #207

Closed
Sorceresssis opened this issue Jul 6, 2024 · 17 comments
Labels
bug Something isn't working

Comments

@Sorceresssis
Copy link

简要描述这个bug

只请求至第5页(102楼),最后一页 (第六页) 的数据请求不到。

如何复现

tid: 2428664072
pn: 6

<2024-07-06 17:16:58.489> [WARN] [get_posts] 'NoneType' object has no attribute 'group'. args=(2428664072, 6) kwargs={'rn': 30, 'with_comments': True}

你希望程序作出何种行为

...

截图(可选)

...

@n0099
Copy link

n0099 commented Jul 6, 2024

@Sorceresssis
Copy link
Author

https://n0099.net/tbm/v1/client_tester.php?type=replies&tid=2428664072&pn=6&client_version=12.62.1.0

就是这些内容。无法使用get_post 获取到。

@n0099
Copy link

n0099 commented Jul 7, 2024

@lumina37
Copy link
Owner

lumina37 commented Jul 8, 2024

我们月中要开MPEG,巨忙,可能得过两个星期才能修了

@lumina37
Copy link
Owner

ce8964e 看看能否解决问题

@lumina37 lumina37 added the bug Something isn't working label Jul 12, 2024
@n0099
Copy link

n0099 commented Jul 12, 2024

https://github.com/Starry-OvO/aiotieba/blob/ce8964eeee78e519289872309cf366ac04602ca1/aiotieba/api/get_comments/_classdef.py#L525-L528

$ curl -s https://n0099.net/tbm/v1/client_tester.php\?type\=replies\&tid\=2428664072\&pn\=6\&client_version\=12.62.1.0 \
| jq '.post_list[] | select(.id == 37592674736) | .content'
[
  {
    "cdn_src_active": "http://c.tieba.baidu.com/c/p/img?src=http://static.tieba.baidu.com/tb/editor/images/qw_cat_small/qw_cat_0004.gif&width=720&height=720&qulity=60&first_gif=1&imgtype=0",
    "type": 3,
    "bsize": "200,200",
    "cdn_src": "http://c.tieba.baidu.com/c/p/img?src=http://static.tieba.baidu.com/tb/editor/images/qw_cat_small/qw_cat_0004.gif&width=720&height=720&qulity=60&first_gif=1&imgtype=0",
    "big_cdn_src": "http://c.tieba.baidu.com/c/p/img?src=http://static.tieba.baidu.com/tb/editor/images/qw_cat_small/qw_cat_0004.gif&width=1920&height=640&qulity=100&first_gif=0&imgtype=0",
    "is_long_pic": 0,
    "show_original_btn": 1
  }
]

https://tieba.baidu.com/p/2428664072?pid=37592674736#37592674736
原来是当年我常发的可自定义填字表情包(这个是没自定义使用预设的几张文本图片)没有origin_src
那我的正义削除 https://github.com/n0099/open-tbm/blob/f2388a78d64ed1123be762f0c212a4f0847a4fbe/c%23/crawler/src/Tieba/Crawl/Parser/Post/ReplyParser.cs#L54-L76 估计也把这仅有的cdn_src给删了,反转了应该没有因为if (!Uri.TryCreate(c.OriginSrc, UriKind.Absolute, out var uri)) continue;

@Sorceresssis
Copy link
Author

还有点小错误。

第 108 楼 post 的图片分块没有 图片源地址。FragImage_p(origin_size=0, show_width=200, show_height=200, hash='')

Post(contents=Contents_p(objs=[FragImage_p(origin_size=0, show_width=200, show_height=200, hash='')]), sign='', comments=[Comment_p(contents=Contents_pc(objs=[FragText(text='谢了\u3000\u3000\u3000\u3000\u3000\u3000\u3000~~~NDS游戏扯淡群 326448723 \u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000')]), fid=500600, fname='nds', tid=2428664072, ppid=37592674736, pid=37593569606, user=UserInfo_p(user_id=418853149, portrait='tb.1.3046e996.ZynDfFdUIQvqbX5YGTPWjA', user_name='8x7y10z4w', nick_name_new='白骨君♀', level=13, glevel=5, gender=<Gender.MALE: 1>, ip='上海', icons=[], is_bawu=False, is_vip=False, is_god=False, priv_like=<PrivLike.HIDE: 3>, priv_reply=<PrivReply.ALL: 1>), author_id=418853149, reply_to_id=0, floor=108, agree=0, disagree=0, create_time=1376991532, is_thread_author=True)], is_aimeme=False, fid=500600, fname='nds', tid=2428664072, pid=37592674736, user=UserInfo_p(user_id=419118212, portrait='tb.1.78172449.txaW3Z8FW70ErVhXYyVqqA', user_name='xky231314', nick_name_new='xky231314', level=8, glevel=0, gender=<Gender.MALE: 1>, ip='', icons=[], is_bawu=False, is_vip=False, is_god=False, priv_like=<PrivLike.PUBLIC: 1>, priv_reply=<PrivReply.ALL: 1>), author_id=419118212, vimage=VirtualImage(enabled=False, state=''), floor=108, reply_num=1, agree=0, disagree=0, create_time=1376990491, is_thread_author=False)

@n0099
Copy link

n0099 commented Jul 12, 2024

第 108 楼 post 的图片分块没有 图片源地址。

#207 (comment)
您得自行对cdn_srcparse url取出querystring之src就像 https://github.com/n0099/open-tbm/blob/f2388a78d64ed1123be762f0c212a4f0847a4fbe/fe/src/utils/post/renderer.ts#L150-L156

@Sorceresssis
Copy link
Author

@n0099 我知道了。但是这个图片的分块没有任何标识。如果在其他帖子里遇到了类似这个的没有任何标识的图片分块。可以认为这个图片分块就是 qw_cat_small/qw_cat_0004.gif 这个表情吗

@n0099
Copy link

n0099 commented Jul 12, 2024

可以认为这个图片分块就是 qw_cat_small/qw_cat_0004.gif 这个表情吗

原来是当年我常发的可自定义填字表情包(这个是没自定义使用预设的几张文本图片)

我记得预设的有9张图,这些表情包还允许自定义气泡中的文本(应该是生成的普通图片从而有origin_src
https://baike.baidu.com/item/神来一句/3118559
https://www.zhihu.com/question/21004343
实际上现在也还有这个神来一句功能(针对某些目录贴吧如您发的这个tid所在的nds吧所在的游戏-其他游戏及话题)只是换了套表情包并且不允许自己填字生成图片
image

@Sorceresssis
Copy link
Author

@n0099 好的,最后一个问题。
FragImage_p(origin_size=0, show_width=200, show_height=200, hash='') 这个分块没有任何唯一标识信息,我无法得知他所指向的是哪个表情。那么贴吧官方客户端,网页端,他们又是如何正确的找到对应的表情的呢。

@n0099
Copy link

n0099 commented Jul 12, 2024

再读一遍 #207 (comment)tl;dr

FragImage_p是aiotieba对PbContent.proto的裁剪后处理(正如同我此前也试图删掉*_cdn_src节省空间)而非原始的PbContent.proto其相当于tbm中对应于存在数据库里的DO实体类

@Sorceresssis
Copy link
Author

我的问题可能很可笑,我很抱歉。
所以你的意思是要我直接去使用下面这个API,解析出图片源是吗?

https://n0099.net/tbm/v1/client_tester.php?type=replies&tid=2428664072&pn=6&client_version=12.62.1.0

https://github.com/n0099/open-tbm/blob/f2388a78d64ed1123be762f0c212a4f0847a4fbe/c%23/crawler/src/Tieba/Crawl/Parser/Post/ReplyParser.cs#L54-L76 实际上我很早就看过了,它似乎只是将URL 简化为仅保留文件名。我没有在这块代码中找到获取表情的方法,所以继续问了很多问题。如果造成了麻烦,我真的很抱歉。

@lumina37
Copy link
Owner

@n0099 好的,最后一个问题。 FragImage_p(origin_size=0, show_width=200, show_height=200, hash='') 这个分块没有任何唯一标识信息,我无法得知他所指向的是哪个表情。那么贴吧官方客户端,网页端,他们又是如何正确的找到对应的表情的呢。

这种没法靠hash区分的罕见情况可能得手动导出url了

@Sorceresssis
Copy link
Author

好的,谢谢你们的帮助!

@n0099
Copy link

n0099 commented Jul 13, 2024

starry神给您构建的DTO抽象中提前优化选择性删+重命名贴吧的PbContent.proto字段
正如同今日份v2ex热议 https://www.v2ex.com/t/1056990

[...]关键是特别喜欢自己转换 rpc 返回的结构,还非要用字典去自定义结构!

#207 (comment)

FragImage_p是aiotieba对PbContent.proto的裁剪后处理

导致您拿不到PbContent.proto中其他的*_cdn_src字段而对于目前这种表情包恰恰需要

#207 (comment)

您得自行对cdn_srcparse url取出querystring之src就像 n0099/open-tbm@f2388a7/fe/src/utils/post/renderer.ts#L150-L156

这本质上跟您上次问的 #202 之底层逻辑完全相同
我不知道starry神为什么要再设计一套抽象而非按原样as-is传递PbContent.proto
我也不知道aiotieba是否有逃生舱允许您绕过这个抽象直接拿到原始的PbContent.proto


#207 (comment)

n0099/open-tbm@f2388a7/c#/crawler/src/Tieba/Crawl/Parser/Post/ReplyParser.cs#L54-L76 实际上我很早就看过了,它似乎只是将URL 简化为仅保留文件名。我没有在这块代码中找到获取表情的方法

我想说的是
#207 (comment)

(正如同我此前也试图删掉*_cdn_src节省空间

而我对PbContent.proto的唯一修改是针对统计上第二常见的type=3图片中的字段进行正义削除只留下文件名hash部分 n0099/open-tbm@8477e81#diff-95921e765722e1b2e2c0ca1a1fe56c7431f408bb154416090f6cf27702806703R55 因为此前我还没大脑升级zfs+zstd透明压缩立省2x压缩比所以需要这样来节省(所有PbContent.protoencoding二进制中的)10%左右存储但现在有了压缩也没必要这样提前优化还打破了不修改贴吧返回的protobuf encoding二进制之承诺(假设protoc所codegen出的parser/encoder可以保证往复一致性(encode(parse(encoding))==encoding),然而目前只知道proto3保证了proto2时的行为:通过parse时放进unknownFields来保留.proto中没定义的fieldnum)

这类有损提前优化并不是真的很有必要,扣代码的时间都折腾好zfs/btrfs透明(或在其他抽象层如许多rdbms也支持表压缩)zstd压缩了


所以你的意思是要我直接去使用下面这个API,解析出图片源是吗?

client_tester.php就是对那3个接口吧首页主题帖 主题帖回复贴 回复贴楼中楼)的json而非protobuf版本(想返回protobuf只是在同一个url endpoint上opt-in几个特征而已)之代理
发这类3接口代理的意思是贴吧方面的raw response是这样

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants