Files
RSSHub/lib/v2/bilibili/utils.js
T
cyx20080216 9cf71fc7a6 feat(route): 添加对哔哩哔哩新接口和校验信息的支持 (#11480)
* feat(route): support verify info for bilibili

* feat(route): add verify info when request

* fix(route): fix the format

Signed-off-by: cyx20080216 <cyx20080216@outlook.com>

* fix(route): fix the error when lint

* fix(route): get verify string from bilibili when it was called

* fix(route): use a simple way to calculate w_rid

* fix(route): get img_url and sub_url from api

* fix(route): get the url of js from space page

* fix(route): add referer

* fix(route): add canonical name

* fix(route): remove unnecessary action

* Update lib/v2/bilibili/utils.js

Signed-off-by: cyx20080216 <cyx20080216@outlook.com>
2022-12-26 15:23:32 +11:00

20 lines
705 B
JavaScript

const crypto = require('crypto');
const iframe = (aid, page, bvid) =>
`<iframe src="https://player.bilibili.com/player.html?${bvid ? `bvid=${bvid}` : `aid=${aid}`}${
page ? `&page=${page}` : ''
}&high_quality=1" width="650" height="477" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe>`;
const addVerifyInfo = (params, verifyString) => {
const md5 = crypto.createHash('md5');
const wts = Math.round(Date.now() / 1000);
const w_rid = md5.update(`${params}&wts=${wts}${verifyString}`).digest('hex');
return `${params}&w_rid=${w_rid}&wts=${wts}`;
};
module.exports = {
iframe,
addVerifyInfo,
bvidTime: 1589990400,
};