/
follow-list.ts
72 lines (67 loc) · 2.13 KB
/
follow-list.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { Route } from '@/types';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { art } from '@/utils/render';
import path from 'node:path';
import cache from './cache';
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
export const route: Route = {
path: '/bbs/follow-list/:uid',
categories: ['game'],
example: '/mihoyo/bbs/follow-list/77005350',
parameters: { uid: '用户uid' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '米游社 - 用户关注',
maintainers: ['CaoMeiYouRen'],
handler,
};
async function handler(ctx) {
const uid = ctx.req.param('uid');
const page_size = ctx.req.query('limit') || '20';
const searchParams = {
gids: 2,
uid,
page_size,
};
const link = `https://www.miyoushe.com/ys/accountCenter/followList?id=${uid}`;
const url = `https://bbs-api.miyoushe.com/user/wapi/following`;
const response = await got({
method: 'get',
url,
searchParams,
headers: {
Origin: 'https://www.miyoushe.com',
Referer: link,
},
});
const list = response?.data?.data?.result;
if (!list) {
throw new Error('未获取到数据!');
}
const { nickname: username } = await cache.getUserFullInfo(ctx, uid);
const title = `米游社 - ${username} 的关注`;
const items = list.map((e) => {
const title = e.user.nickname;
const link = `https://www.miyoushe.com/ys/accountCenter/postList?id=${e.user.uid}`;
const description = renderDescription(`${e.user.certification.label || ''}\n${e.user.introduce || ''}`.trim(), [e.user.avatar_url]);
return {
title,
link,
description,
};
});
const data = {
title,
link,
item: items,
};
return data;
}