-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add get_short_url to generate the b23.tv url from the bilibili.com url #720
base: dev
Are you sure you want to change the base?
Conversation
…libili.com url and acquire_buvid method
…parameter for get_real_url in docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个接口的鉴权是 APP 鉴权吧? sessdata 的能用?
bilibili_api/utils/short.py
Outdated
# random generation | ||
buvid3_pattern = '8-4-4-4-17' # current buvid3 char-length pattern, might be changed later | ||
parts = buvid3_pattern.split('-') | ||
|
||
buvid3_rand_gen = ["".join(random.choices(string.digits + string.ascii_letters, k=int(part))) for part in parts] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议随机,有spi接口可以用
bilibili_api/utils/short.py
Outdated
'platform': random.choice(['android', 'ios']), | ||
'share_channel': 'COPY', | ||
'share_id': 'public.webview.0.0.pv', | ||
'share_mode': str(random.randint(1, 10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不了解的参数可以照旧,build 也是
…rams for post_data
|
随机 buvid 没有意义...没有 buvid 就应该去 spi 获取...没查是一回事 这个接口你测试过不需要登录吗?你说 sessdata 不能用,我记得我也没写 app 鉴权,那你咋请求的?有测试数据提供一份吗? 麻烦固定 build,不同 build 的参数可能不同 |
他需要什么他会写出来,你可以试一下 {'code': -400, 'message': "Key: 'ClickReq.ShareId' Error:Field validation for 'ShareId' failed on the 'required' tag\nKey: 'ClickReq.Oid' Error:Field validation for 'Oid' failed on the 'required' tag\nKey: 'ClickReq.ShareMode' Error:Field validation for 'ShareMode' failed on the 'required' tag\nKey: 'ClickReq.ShareChannel' Error:Field validation for 'ShareChannel' failed on the 'required' tag\nKey: 'ClickReq.Buvid' Error:Field validation for 'Buvid' failed on the 'required' tag\nKey: 'ClickReq.Platform' Error:Field validation for 'Platform' failed on the 'required' tag", 'ttl': 1} 其中
{'code': 0, 'message': '0', 'ttl': 1, 'data': {'count': 0}} 所以,他现在不查 P.S. 正常返回的情况,json会像这样 {'code': 0, 'message': '0', 'ttl': 1, 'data': {'content': 'https://b23.tv/UfikcVQ', 'count': 0}} |
主要是不需要登录吗?就算不需要,可以考虑下等我这周末把APP鉴权加进去之后再合并,这个短链接能识别分享者的 |
还真不用登录啊...那我想摆烂了,继续鸽着登录吧,没啥意义+-= |
基本上,如果 视频只能 我觉得需要捕捉点
|
动态
|
专栏
|
文集
|
直播
|
用户
|
课程 |
番剧
|
基本上,我没时间...如果你打算做的话,上面这些是不同类型 oid 对应的 如果你没想法的话,直接只支持把网址缩短就行,那我就直接合并,上面留着备忘 如果你要做的话踢一下我,PR 放着先不合并 @TimG233 |
不需要 try,不成功就应该报错
ok感谢! 我下周有时间看一下怎么改改比较好 |
之前各种事情有些忙碌,耽搁了一阵。 |
添加了
get_short_url
来生成b23
的短链接buvid
,若没传入或buvid
为None
,则随机生成buvid
(同一个文件的acquire_buvid
方法里)。移除了
get_real_url
的credential
参数更新了
docs
来源:#702
代码水平有限,大佬们多指点!感谢!