diff --git a/lib/routes/bangumi.tv/user/collections.ts b/lib/routes/bangumi.tv/user/collections.ts index cdf5b105b1af52..dc4676445161b4 100644 --- a/lib/routes/bangumi.tv/user/collections.ts +++ b/lib/routes/bangumi.tv/user/collections.ts @@ -1,5 +1,5 @@ import { Route } from '@/types'; -import got from '@/utils/got'; +import ofetch from '@/utils/ofetch'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; @@ -89,9 +89,26 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, - radar: [], + radar: [ + { + source: ['bgm.tv/anime/list/:id'], + target: '/bangumi.tv/user/collections/:id/all/all', + }, + { + source: ['bangumi.tv/anime/list/:id'], + target: '/bangumi.tv/user/collections/:id/all/all', + }, + { + source: ['bgm.tv/anime/list/:id/wish'], + target: '/bangumi.tv/user/collections/:id/2/1', + }, + { + source: ['bangumi.tv/anime/list/:id/wish'], + target: '/bangumi.tv/user/collections/:id/2/1', + }, + ], name: 'Bangumi 用户收藏列表', - maintainers: ['youyou-sudo'], + maintainers: ['youyou-sudo', 'honue'], handler, }; @@ -125,23 +142,21 @@ async function handler(ctx) { } const userDataUrl = `https://api.bgm.tv/v0/users/${userId}`; - const userData = await got(userDataUrl, { - method: 'get', + const userData = await ofetch(userDataUrl, { headers: { 'User-Agent': config.trueUA, }, }); const collectionDataUrl = `https://api.bgm.tv/v0/users/${userId}/collections?${subjectType && subjectType !== 'all' ? `subject_type=${subjectType}` : ''}${type && type !== 'all' ? `&type=${type}` : ''}`; - const collectionData = await got(collectionDataUrl, { - method: 'get', + const collectionData = await ofetch(collectionDataUrl, { headers: { 'User-Agent': config.trueUA, }, }); - const userNickname = userData.data.nickname; - const items = collectionData.data.data.map((item) => { + const userNickname = userData.nickname; + const items = collectionData.data.map((item) => { const titles = item.subject.name_cn || item.subject.name; const updateTime = item.updated_at; const subjectId = item.subject_id; @@ -160,7 +175,6 @@ async function handler(ctx) { }), link: `https://bgm.tv/subject/${subjectId}`, pubDate: timezone(parseDate(updateTime), 0), - urls: `https://bgm.tv/subject/${subjectId}`, }; }); return { diff --git a/lib/routes/bangumi.tv/user/wish.ts b/lib/routes/bangumi.tv/user/wish.ts deleted file mode 100644 index b28897ca871bd0..00000000000000 --- a/lib/routes/bangumi.tv/user/wish.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Route } from '@/types'; -import got from '@/utils/got'; -import { load } from 'cheerio'; -import timezone from '@/utils/timezone'; -import { parseDate } from '@/utils/parse-date'; -import { config } from '@/config'; -export const route: Route = { - path: '/user/wish/:id', - categories: ['anime'], - example: '/bangumi.tv/user/wish/sai', - parameters: { id: '用户 id, 在用户页面地址栏查看' }, - features: { - requireConfig: false, - requirePuppeteer: false, - antiCrawler: false, - supportBT: false, - supportPodcast: false, - supportScihub: false, - }, - radar: [ - { - source: ['bgm.tv/anime/list/:id/wish'], - }, - ], - name: '用户想看', - maintainers: ['honue'], - handler, -}; - -async function handler(ctx) { - const userid = ctx.req.param('id'); - const url = `https://bgm.tv/anime/list/${userid}/wish`; - const response = await got({ - url, - method: 'get', - headers: { - 'User-Agent': config.trueUA, - }, - }); - const $ = load(response.body); - - const username = $('.name').find('a').html(); - const items = $('#browserItemList') - .find('li') - .toArray() - .map((item) => { - const aTag = $(item).find('h3').children('a'); - const jdate = $(item).find('.collectInfo').find('span').html(); - return { - title: aTag.html(), - link: 'https://bgm.tv' + aTag.attr('href'), - pubDate: timezone(parseDate(jdate), 0), - }; - }); - - return { - title: `${username}想看的动画`, - link: url, - item: items, - description: `${username}想看的动画列表`, - }; -}