fix(route): bilibili vsearch (#10681)
This commit is contained in:
parent
ad74376adb
commit
7036f4b78b
|
|
@ -1,6 +1,8 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const utils = require('./utils');
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
const cookieJar = new CookieJar();
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const kw = ctx.params.kw;
|
||||
|
|
@ -9,18 +11,28 @@ module.exports = async (ctx) => {
|
|||
const kw_url = encodeURIComponent(kw);
|
||||
const tids = ctx.params.tid ?? 0;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=video&highlight=1&keyword=${kw_url}&order=${order}&duration=0&single_column=0&tids=${tids}`,
|
||||
await got('https://www.bilibili.com', {
|
||||
cookieJar,
|
||||
});
|
||||
|
||||
const response = await got('https://api.bilibili.com/x/web-interface/search/type', {
|
||||
headers: {
|
||||
Referer: `https://search.bilibili.com/all?keyword=${kw_url}`,
|
||||
},
|
||||
cookieJar,
|
||||
searchParams: {
|
||||
search_type: 'video',
|
||||
highlight: 1,
|
||||
keyword: kw,
|
||||
order,
|
||||
tids,
|
||||
},
|
||||
});
|
||||
const data = response.data.data.result;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${kw} - bilibili`,
|
||||
link: `https://search.bilibili.com/all?keyword=${kw_url}&order=${order}`,
|
||||
link: `https://search.bilibili.com/all?keyword=${kw}&order=${order}`,
|
||||
description: `Result from ${kw} bilibili search, ordered by ${order}.`,
|
||||
item: data.map((item) => {
|
||||
const l = item.duration
|
||||
|
|
@ -42,7 +54,7 @@ module.exports = async (ctx) => {
|
|||
`<img src="${img}"><br/>` +
|
||||
`Match By: ${item.hit_columns.join(',')}` +
|
||||
(!disableEmbed ? `<br><br>${utils.iframe(item.aid)}` : ''),
|
||||
pubDate: parseDate(item.pubdate * 1000),
|
||||
pubDate: parseDate(item.pubdate, 'X'),
|
||||
guid: item.arcurl,
|
||||
link: item.arcurl,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue