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

关于DDBOT订阅B站用户返回403、799错误码以及下播封面出不来的问题 #231

Open
why0209 opened this issue May 24, 2023 · 2 comments

Comments

@why0209
Copy link

why0209 commented May 24, 2023

近期在使用/watch时出现该错误码以及下播后显示[封面]的问题。
是由于https://api.bilibili.com/x/space/wbi/acc/info?mid=2接口增加了w_rid验证所导致的。
具体签名算法可移步https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/misc/sign/wbi.md

目前暂行的解决办法是
① 使用如下PHP代码(因为我只会PHP)搭建HTTP服务。

`<?php
$GLOBALS['uid'] = $_GET['mid'];

if (empty($_GET['mid'])) {
exit;
}

//目录下的rrid.json文件
$rrid = json_decode(get("http://127.0.0.1/rrid.json",""),true, 512, JSON_BIGINT_AS_STRING);
$img_url = $rrid['img_url'];
$sub_url = $rrid['sub_url'];

$mb_img = explode("/",$img_url);
$mb_sub = explode("/",$sub_url);

$img_value = explode(".",$mb_img[count($mb_img) - 1])[0];
$sub_value = explode(".",$mb_sub[count($mb_sub) - 1])[0];

//时间戳
$wts = time();
$pdArray = array(
"mid" => (int)$uid,
"platform" => "web",
"token" => "",
"web_location" => "1550101",
"wts" => $wts
);

$pdData = http_build_query($pdArray);
$w_rid = md5($pdData.getMixKey($img_value.$sub_value));
header('content-type:application/json');
echo get("https://api.bilibili.com/x/space/wbi/acc/info?mid=$uid&token=&platform=web&web_location=1550101&w_rid=$w_rid&wts=$wts","");
exit;

//获取MixKey
function getMixKey($res){
$oe = array(46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39,12, 38, 41,13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62,11, 36, 20, 34, 44, 52);
$le = array();
for ($i = 0; $i < count($oe); $i++) {
$le[] = $res[$oe[$i]];
}
return mb_substr(implode($le),0,32);
}

//GET请求
function get($url, $cookie) {//url为必传、若无cookie则传空字符串
if (empty($url)) {
return false;
}
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
if(strpos($url, 'https://')!== false){ //判断请求协议http或https
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在
}
curl_setopt($ch, CURLOPT_REFERER, "https://space.bilibili.com/".$GLOBALS['uid']."?spm_id_from=333.1007.0.0");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36"); // 模拟用户使用的浏览器
if(!empty($cookie))curl_setopt($ch,CURLOPT_COOKIE,$cookie); //设置cookie
$data = curl_exec($ch);//运行curl
curl_close($ch);
return $data;
}`

JSON文件内容(该内容可能有变化,参考签名算法的git):
{"img_url":"https://i0.hdslb.com/bfs/wbi/9cd4224d4fe74c7e9d6963e2ef891688.png","sub_url":"https://i0.hdslb.com/bfs/wbi/263655ae2cad4cce95c9c401981b044a.png"}

② 下载DDBOT源码,分别更改lsp/bilibili/bilibili.go 中的第34行,xSpaceAccInfo.go的第15行
image
image

③ 重新编译即可正常进行/watch订阅,搭建好的接口可以供其他用户使用。

此方法为暂行的解决办法,如不想使用此方法请等待开发者更新!

@Waldo-Schaeffer
Copy link

谢谢大佬热修

@Sora233
Copy link
Owner

Sora233 commented May 24, 2023

CI#1289 试下这个版本

@Sora233 Sora233 pinned this issue May 24, 2023
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

3 participants