fix(route/bilibili): fix liveSearch (#12772)
* fix(route/bilibili):fix liveSearch * style: auto format * Update liveSearch.js fix order not deliver to param remove qv_id remove fixed UA --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
1de2457216
commit
252f53beb5
|
|
@ -1,4 +1,6 @@
|
|||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
const cache = require('./cache');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const key = ctx.params.key;
|
||||
|
|
@ -15,26 +17,32 @@ module.exports = async (ctx) => {
|
|||
orderTitle = '人气直播';
|
||||
break;
|
||||
}
|
||||
const verifyString = await cache.getVerifyString(ctx);
|
||||
let params = `__refresh__=true&_extra=&context=&page=1&page_size=42&order=${order}&duration=&from_source=&from_spmid=333.337&platform=pc&highlight=1&single_column=0&keyword=${urlEncodedKey}&ad_resource=&source_tag=3&gaia_vtoken=&category_id=&search_type=live&dynamic_offset=0&web_location=1430654`;
|
||||
params = utils.addVerifyInfo(params, verifyString);
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/web-interface/search/type?search_type=live_room&keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1`,
|
||||
url: `https://api.bilibili.com/x/web-interface/wbi/search/type?${params}`,
|
||||
headers: {
|
||||
Referer: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`,
|
||||
Referer: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&from_source=webtop_search&spm_id_from=444.7&search_source=3&search_type=live_room`,
|
||||
Cookie: await cache.getCookie(ctx),
|
||||
},
|
||||
});
|
||||
const data = response.data.data.result;
|
||||
const data = response.data.data.result.live_room;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `哔哩哔哩直播-${key}-${orderTitle}`,
|
||||
link: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`,
|
||||
description: `哔哩哔哩直播-${key}-${orderTitle}`,
|
||||
item: data.map((item) => ({
|
||||
title: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
|
||||
description: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
|
||||
pubDate: new Date(item.live_time.replace(' ', 'T') + '+08:00').toUTCString(),
|
||||
guid: `https://live.bilibili.com/${item.roomid} ${item.live_time}`,
|
||||
link: `https://live.bilibili.com/${item.roomid}`,
|
||||
})),
|
||||
item:
|
||||
data &&
|
||||
data.map((item) => ({
|
||||
title: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
|
||||
description: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
|
||||
pubDate: new Date(item.live_time.replace(' ', 'T') + '+08:00').toUTCString(),
|
||||
guid: `https://live.bilibili.com/${item.roomid} ${item.live_time}`,
|
||||
link: `https://live.bilibili.com/${item.roomid}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue