Skip to content

Commit

Permalink
feat!: remove /user/wish/:id since it's equivalent to /user/collect…
Browse files Browse the repository at this point in the history
…ions/:id/2/1
  • Loading branch information
TonyRL committed Oct 24, 2024
1 parent 927881a commit 772437e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 72 deletions.
34 changes: 24 additions & 10 deletions lib/routes/bangumi.tv/user/collections.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
62 changes: 0 additions & 62 deletions lib/routes/bangumi.tv/user/wish.ts

This file was deleted.

0 comments on commit 772437e

Please sign in to comment.