fix: B站非默认收藏夹失效 (#2433)
fix #2430 Co-authored-by: qixingchen <i@loli.xing.moe>
This commit is contained in:
parent
a92f69cfac
commit
1b632a3e8d
|
|
@ -74,33 +74,6 @@ module.exports = {
|
|||
}
|
||||
return name;
|
||||
},
|
||||
getFavNameFromFid: async (ctx, fid, uid) => {
|
||||
const key = `bili-favName-from-fid-${fid}`;
|
||||
let name = await ctx.cache.get(key);
|
||||
|
||||
if (!name) {
|
||||
const nameResponse = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/space/fav/nav?mid=${uid}`,
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/#/favlist`,
|
||||
},
|
||||
});
|
||||
if (nameResponse && nameResponse.data && nameResponse.data.data && nameResponse.data.data.archive) {
|
||||
nameResponse.data.data.archive.forEach((item) => {
|
||||
// noinspection EqualityComparisonWithCoercionJS
|
||||
if (fid === item.fid.toString()) {
|
||||
name = item.name;
|
||||
}
|
||||
});
|
||||
}
|
||||
ctx.cache.set(key, name);
|
||||
}
|
||||
if (!name) {
|
||||
name = 'Unknown';
|
||||
}
|
||||
return name;
|
||||
},
|
||||
getCidFromAid: async (ctx, aid, pid) => {
|
||||
const key = `bili-Cid-from-Aid-${aid}-${pid}`;
|
||||
let cid = await ctx.cache.get(key);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
const got = require('@/utils/got');
|
||||
const cache = require('./cache');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const fid = ctx.params.fid;
|
||||
|
|
@ -7,14 +6,14 @@ module.exports = async (ctx) => {
|
|||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/v2/fav/video?vmid=${uid}&fid=${fid}`,
|
||||
url: `https://api.bilibili.com/medialist/gateway/base/spaceDetail?media_id=${fid}&pn=1&ps=20&keyword=&order=mtime&type=0&tid=0`,
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
},
|
||||
});
|
||||
const data = response.data.data;
|
||||
const userName = await cache.getUsernameFromUID(ctx, uid);
|
||||
const favName = await cache.getFavNameFromFid(ctx, fid, uid);
|
||||
const userName = data.info.upper.name;
|
||||
const favName = data.info.title;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${userName} 的 bilibili 收藏夹 ${favName}`,
|
||||
|
|
@ -23,12 +22,12 @@ module.exports = async (ctx) => {
|
|||
|
||||
item:
|
||||
data &&
|
||||
data.archives &&
|
||||
data.archives.map((item) => ({
|
||||
data.medias &&
|
||||
data.medias.map((item) => ({
|
||||
title: item.title,
|
||||
description: `${item.desc}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
|
||||
pubDate: new Date(item.fav_at * 1000).toUTCString(),
|
||||
link: `https://www.bilibili.com/video/av${item.aid}`,
|
||||
description: `${item.intro}`,
|
||||
pubDate: new Date(item.fav_time * 1000).toUTCString(),
|
||||
link: `https://www.bilibili.com/${item.link.replace('bilibili://video/', 'video/av')}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue