关于获取视频网址的问题 返回404 啥都木有 #1138
-
const { domainCookies } = options;
const basicHeaders = createBasicWebBrowserHeaders({
"Cookie": domainCookies,
"Referer": "https://www.bilibili.com/"
});
const ret = {
success: false,
urls: [],
headers: []
};
if (domainCookies) {
ret.headers.push({ name: "Cookie", value: domainCookies });
}
const params = {
avid: vars.aid,
cid: vars.cid,
qn: 64,
type: "",
otype: "json",
platform: "html5",
high_quality: 1
}
const sessionData = domainCookies.split(";").find(item => item.includes("SESSDATA="));
if (!sessionData) {
console.error("SESSDATA not found");
return;
}
const queryString = await getWbiKeysAsync(sessionData, params);
const videoAPI = `https://api.bilibili.com/x/player/wbi/playurl?${queryString}`;
console.log(videoAPI);
console.log(basicHeaders);
try {
const response = await fetch(videoAPI, { headers: basicHeaders });
const v_detail = await response.json();
console.log(v_detail);
return;
ret.success = true;
ret.urls.push(url);
} catch (error) {
console.error(error);
}
return ret; 签名计算使用了 wbi签名 api url : https://api.bilibili.com/x/player/wbi/playurl?avid=328492664&cid=197711172&high_quality=1&otype=json&platform=html5&qn=64&type=&wts=1731519430&w_rid=xxxxxxxxxxxx |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
此视频实际上为剧集,建议使用剧集的获取播放地址的 API 如您仍想使用此 API,经过我的测试,若请求参数中
{
"code": 0,
"message": "0",
"ttl": 1,
"data": {
"from": "local",
"result": "suee",
"message": "",
"quality": 16,
"format": "mp4",
"timelength": 2783920,
"accept_format": "mp4,mp4",
"accept_description": [
"高清 1080P",
"流畅 360P"
],
"accept_quality": [
80,
16
],
"video_codecid": 7,
"seek_param": "start",
"seek_type": "second",
"durl": [
{
"order": 1,
"length": 2783920,
"size": 147040825,
"ahead": "",
"vhead": "",
"url": "https://upos-sz-estghw.bilivideo.com/upgcxcode/72/11/197711172/197711172_da8-1-16.mp4?e=***&uipk=5&nbs=1&deadline=1731529599&gen=playurlv2&os=upos&oi=0&trid=7677fe8181b04577bc93ea63cfe26fc7u&mid=0&platform=pc&og=08&upsig=e0bb8a4714e289d9e2a91fe0b379f4c0&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform,og&bvc=vod&nettype=0&orderid=0,3&buvid=&build=0&f=u_0_0&agrr=1&bw=52835&logo=80000000",
"backup_url": [
"https://upos-sz-estghw.bilivideo.com/upgcxcode/72/11/197711172/197711172_da8-1-16.mp4?e=***&uipk=5&nbs=1&deadline=1731529599&gen=playurlv2&os=upos&oi=0&trid=7677fe8181b04577bc93ea63cfe26fc7u&mid=0&platform=pc&og=08&upsig=e0bb8a4714e289d9e2a91fe0b379f4c0&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform,og&bvc=vod&nettype=0&orderid=1,3&buvid=&build=0&f=u_0_0&agrr=1&bw=52835&logo=40000000",
"https://upos-sz-estghw.bilivideo.com/upgcxcode/72/11/197711172/197711172_da8-1-16.mp4?e=***&uipk=5&nbs=1&deadline=1731529599&gen=playurlv2&os=upos&oi=0&trid=7677fe8181b04577bc93ea63cfe26fc7u&mid=0&platform=pc&og=08&upsig=e0bb8a4714e289d9e2a91fe0b379f4c0&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform,og&bvc=vod&nettype=0&orderid=2,3&buvid=&build=0&f=u_0_0&agrr=1&bw=52835&logo=40000000"
]
}
],
"support_formats": [
{
"quality": 80,
"format": "mp4",
"new_description": "1080P 高清",
"display_desc": "1080P",
"superscript": "",
"codecs": null
},
{
"quality": 16,
"format": "mp4",
"new_description": "360P 流畅",
"display_desc": "360P",
"superscript": "",
"codecs": null
}
],
"high_format": null,
"last_play_time": 0,
"last_play_cid": 0,
"view_info": null
}
} |
Beta Was this translation helpful? Give feedback.
此视频实际上为剧集,建议使用剧集的获取播放地址的 API
如您仍想使用此 API,经过我的测试,若请求参数中
platform=html5
则返回-404
错误码,修改成platform=pc
后即可正常返回结果https://api.bilibili.com/x/player/wbi/playurl?avid=328492664&cid=197711172&high_quality=1&otype=json&platform=web&qn=64&type=&w_webid=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzcG1faWQiOiIwLjAiLCJ1c2VyX2FnZW50IjoiTW96aWxsYS81LjAgKFgxMTsgTGludXggeDg2XzY0KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvMTIzLjAuMC4wIFNhZmFyaS81MzcuMzYiLCJiaWxpX3RpY2tldCI6IjQ3MmM2OTYxNTMxYmIyNmY2NDJmOGVlMTc0YWJiMzczIiwiY3JlYXRlZF9hdCI6MTczMTUyMjIwMiwidHRsIjo4NjQwMCwidXJsIjoiLzQyNTUwMzkxMyIsInJlc3VsdCI6Im5vcm1hbCIsImlzcyI6ImdhaWEiLCJpYXQiOjE3MzE1MjIyMDJ9.WLzCcytMwckknm7y7SELZ563SAL0IUErJUDg…