From 1b632a3e8dc474df0546342dfee63172e51837ee Mon Sep 17 00:00:00 2001 From: qixingchen Date: Tue, 18 Jun 2019 16:13:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20B=E7=AB=99=E9=9D=9E=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=A4=B9=E5=A4=B1=E6=95=88=20(#2433)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #2430 Co-authored-by: qixingchen --- lib/routes/bilibili/cache.js | 27 --------------------------- lib/routes/bilibili/fav.js | 17 ++++++++--------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/lib/routes/bilibili/cache.js b/lib/routes/bilibili/cache.js index d2fe80200..8693fffc9 100644 --- a/lib/routes/bilibili/cache.js +++ b/lib/routes/bilibili/cache.js @@ -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); diff --git a/lib/routes/bilibili/fav.js b/lib/routes/bilibili/fav.js index 5e4d5adb5..af7b02bc0 100644 --- a/lib/routes/bilibili/fav.js +++ b/lib/routes/bilibili/fav.js @@ -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}
`, - 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')}`, })), }; };