feat(route): bilibili route add author and date (#7770)
This commit is contained in:
parent
d51179bd0e
commit
de8d4a0c09
|
|
@ -1,6 +1,7 @@
|
|||
const got = require('@/utils/got');
|
||||
const cache = require('./cache');
|
||||
const utils = require('./utils');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
|
|
@ -9,13 +10,15 @@ module.exports = async (ctx) => {
|
|||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/space/coin/video?vmid=${uid}&jsonp=jsonp`,
|
||||
url: `https://api.bilibili.com/x/space/coin/video?vmid=${uid}`,
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
},
|
||||
});
|
||||
const data = response.data.data;
|
||||
const { data, code, message } = response.data;
|
||||
if (code) {
|
||||
throw new Error(message ? message : code);
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name} 的 bilibili 投币视频`,
|
||||
|
|
@ -23,9 +26,10 @@ module.exports = async (ctx) => {
|
|||
description: `${name} 的 bilibili 投币视频`,
|
||||
item: data.map((item) => ({
|
||||
title: item.title,
|
||||
description: `${item.desc}${!disableEmbed ? `<br><br>${utils.iframe(item.aid)}` : ''}<br><img src="${item.pic}">`,
|
||||
pubDate: new Date(item.time * 1000).toUTCString(),
|
||||
description: `${item.desc}${!disableEmbed ? `<br><br>${utils.iframe(item.aid)}` : ''}<br><img src='${item.pic}'>`,
|
||||
pubDate: parseDate(item.time * 1000),
|
||||
link: item.time > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
|
||||
author: item.owner.name,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const fid = ctx.params.fid;
|
||||
|
|
@ -7,13 +8,16 @@ module.exports = async (ctx) => {
|
|||
const disableEmbed = ctx.params.disableEmbed;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/medialist/gateway/base/spaceDetail?media_id=${fid}&pn=1&ps=20&keyword=&order=mtime&type=0&tid=0`,
|
||||
url: `https://api.bilibili.com/x/v3/fav/resource/list?media_id=${fid}&ps=20`,
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
},
|
||||
});
|
||||
const data = response.data.data;
|
||||
const { data, code, message } = response.data;
|
||||
if (code) {
|
||||
throw new Error(message ? message : code);
|
||||
}
|
||||
|
||||
const userName = data.info.upper.name;
|
||||
const favName = data.info.title;
|
||||
|
||||
|
|
@ -26,8 +30,8 @@ module.exports = async (ctx) => {
|
|||
data.medias &&
|
||||
data.medias.map((item) => ({
|
||||
title: item.title,
|
||||
description: `${item.intro}${!disableEmbed ? `<br><br>${utils.iframe(item.id)}` : ''}<br><img src="${item.cover}">`,
|
||||
pubDate: new Date(item.fav_time * 1000).toUTCString(),
|
||||
description: `${item.intro}${!disableEmbed ? `<br><br>${utils.iframe(item.id)}` : ''}<br><img src='${item.cover}'>`,
|
||||
pubDate: parseDate(item.fav_time * 1000),
|
||||
link: item.fav_time > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.id}`,
|
||||
author: item.upper.name,
|
||||
})),
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ module.exports = async (ctx) => {
|
|||
description: `${item.desc}${!disableEmbed ? `<br><br>${utils.iframe(item.aid)}` : ''}<br><img src="${item.pic}">`,
|
||||
pubDate: new Date(item.fav_at * 1000).toUTCString(),
|
||||
link: item.fav_at > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
|
||||
author: item.owner.name,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue