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

v4.10.6录播功能失效 #38

Open
TiAmoPlus opened this issue Apr 21, 2024 · 5 comments
Open

v4.10.6录播功能失效 #38

TiAmoPlus opened this issue Apr 21, 2024 · 5 comments

Comments

@TiAmoPlus
Copy link
Contributor

应该是阿b对录播接口进行了限制。
当用https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo 接口获取ts/m3u8链接时。
不能只拼接host+base_url了,还应该+extra字段了。extra字段补充的应该是get请求的参数,可能以前阿b对参数没有限制,但是现在有限制了。
相关代码片段应该在bili_liveservice.cpp:3875行左右。
image

同时,因为完整的url带了参数,也就是不是以?结尾的了。还需要修改
void M3u8Downloader::start(QString url, QString file)方法。重新修改截取domain_url的逻辑。
相关代码在m3u8downloader.cpp:39行
image

由于我提供逻辑,会把最后一个/给过滤掉。还得修改void M3u8Downloader::parseM3u8(const QByteArray &data)方法,修改拼接ts_url
相关代码在m3u8downloader.cpp:137行
image

@iwxyi
Copy link
Owner

iwxyi commented Apr 22, 2024

添加extra后依旧是403 Forbidden,是不是还缺了什么?

@TiAmoPlus
Copy link
Contributor Author

你可能得看下m3u8downloader.cpp的void M3u8Downloader::start(QString url, QString file)方法
因为这个方法从一个完整url获取domain_url的时候会有问题
举个例子
https://d1--cn-gotcha104.bilivideo.com/live-bvc/485954/live_13904372_8415339.m3u8?expires=1713788519&len=0&oi=245063906&pt=web&qn=10000&trid=1003e5233bc5da7f4624880284eb8d5fcd0d&sigparams=cdn,expires,len,oi,pt,qn,trid&cdn=cn-gotcha104&sign=837d68d14feb9536c6d4b2b5b97b3075&sk=434112ac5c46ef5c1f5e25412cff4a4d&p2p_type=1&sl=1&free_type=0&mid=140956254&pp=rtmp&source=onetier&trace=10&site=38985dbb2b24077a4a616d6a6c427466&order=1
这是一个补充了extra参数的url
但是domain_url得截取逻辑会截取为https://d1--cn-gotcha104.bilivideo.com/
后面拼接ts_url的就会有问题。比如有一个ts文件是live_13904372_8415339-1713785561.ts
正确的获取文件数据,正确的ts_url应该是https://d1--cn-gotcha104.bilivideo.com/live-bvc/485954/live_13904372_8415339-1713785561.ts
而不是https://d1--cn-gotcha104.bilivideo.com/live_13904372_8415339-1713785561.ts
所以你不能只是补充了extra就可以了,还得修改M3u8Downloader这个类里的一部分逻辑

@TiAmoPlus
Copy link
Contributor Author

这个好像我还是没修复好,在extra字段里有个expires参数,如果录制的时间戳超过这个的话,应该要去重新获取直播流地址,再继续录制的。。。这个如果我能修复的好,我想办法提供出来吧。。

@TiAmoPlus
Copy link
Contributor Author

作者,看了你的提交记录,请你再仔细看下m3u8downloader.cpp的提交记录和我给出的修改方案,
把indexOf改为lastIndexOf后,请去掉第二个参数pos。

@TiAmoPlus
Copy link
Contributor Author

目前这个录播功能应该是修复了。测过的。
也提交了一个pr
Bugfix record 修复第一次提交代码的bug&修复录制时间超出expires后无法继续录制的bug #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants