diff --git a/lib/routes/eastmoney/gerenzhongxin/cfh.ts b/lib/routes/eastmoney/gerenzhongxin/cfh.ts new file mode 100644 index 000000000..883f99075 --- /dev/null +++ b/lib/routes/eastmoney/gerenzhongxin/cfh.ts @@ -0,0 +1,68 @@ +import { Route, ViewType } from '@/types'; +import { parseDate } from '@/utils/parse-date'; +import got from '@/utils/got'; +import timezone from '@/utils/timezone'; + +export const route: Route = { + path: '/gerenzhongxin/cfh/:uid', + categories: ['finance'], + view: ViewType.Articles, + example: '/eastmoney/gerenzhongxin/cfh/2922094262312522', + parameters: { uid: '用户id,即用户主页网址末尾的数字' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['guba.eastmoney.com'], + }, + { + source: ['caifuhao.eastmoney.com'], + }, + { + source: ['i.eastmoney.com/:uid'], + target: '/gerenzhongxin/cfh/:uid', + }, + ], + name: '个人中心长文', + maintainers: ['AwesomeDog'], + handler, +}; + +export async function handler(ctx) { + const uid = ctx.req.param('uid'); + const url = `https://i.eastmoney.com/api/guba/postCenterList?uid=${uid}&pagenum=1&pagesize=10&type=1&filterType=1&onlyYt=0`; + + const response = await got(url); + const arr = response.data.result; + // console.log(arr[0].post_user); + const nickname = arr[0].post_user.user_nickname; + + const items = arr.map((item) => { + let descriptionContent = item.post_content; + if (item.post_pic_url && item.post_pic_url.length > 0) { + const imagesHTML = item.post_pic_url.map((url: string) => ``).join(''); + descriptionContent += '
' + imagesHTML; + } + + return { + title: item.post_title || `${nickname} 发布了长文: ${descriptionContent}`, + description: descriptionContent, + pubDate: timezone(parseDate(item.post_publish_time), 8), + link: `https://caifuhao.eastmoney.com/news/${item.post_source_id}`, + author: item.post_user.user_nickname, + }; + }); + + return { + title: `${nickname} 的东财长文`, + link: `https://i.eastmoney.com/${uid}#cfh`, + image: `https://avator.eastmoney.com/qface/${uid}/360`, + item: items, + }; +} diff --git a/lib/routes/eastmoney/gerenzhongxin/gather.ts b/lib/routes/eastmoney/gerenzhongxin/gather.ts new file mode 100644 index 000000000..79d9505e2 --- /dev/null +++ b/lib/routes/eastmoney/gerenzhongxin/gather.ts @@ -0,0 +1,69 @@ +import { type Route, ViewType } from '@/types'; +import { handler as cfhHandler } from './cfh'; +import { handler as gubaHandler } from './guba'; +import { handler as trplHandler } from './trpl'; + +export const route: Route = { + path: '/gerenzhongxin/gather/:uid', + categories: ['finance'], + view: ViewType.Articles, + example: '/eastmoney/gerenzhongxin/gather/2922094262312522', + parameters: { uid: '用户id,即用户主页网址末尾的数字' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['guba.eastmoney.com'], + }, + { + source: ['caifuhao.eastmoney.com'], + }, + { + source: ['i.eastmoney.com/:uid'], + target: '/gerenzhongxin/gather/:uid', + }, + ], + name: '个人中心所有活动', + maintainers: ['AwesomeDog'], + handler, +}; + +async function handler(ctx) { + const uid = ctx.req.param('uid'); + + const subCtx = { + req: { + param: (key: string) => (key === 'uid' ? uid : ''), + }, + }; + const [cfhResult, gubaResult, trplResult] = await Promise.allSettled([cfhHandler(subCtx), gubaHandler(subCtx), trplHandler(subCtx)]); + + const allItems: any[] = []; + + if (cfhResult.status === 'fulfilled') { + allItems.push(...cfhResult.value.item); + } + if (gubaResult.status === 'fulfilled') { + allItems.push(...gubaResult.value.item); + } + if (trplResult.status === 'fulfilled') { + allItems.push(...trplResult.value.item); + } + + allItems.sort((a, b) => b.pubDate.getTime() - a.pubDate.getTime()); + + const nickname = allItems[0]?.author || '用户'; + + return { + title: `${nickname} 的东财所有活动`, + link: `https://i.eastmoney.com/${uid}`, + image: `https://avator.eastmoney.com/qface/${uid}/360`, + item: allItems, + }; +} diff --git a/lib/routes/eastmoney/gerenzhongxin/guba.ts b/lib/routes/eastmoney/gerenzhongxin/guba.ts new file mode 100644 index 000000000..082d2d105 --- /dev/null +++ b/lib/routes/eastmoney/gerenzhongxin/guba.ts @@ -0,0 +1,68 @@ +import { Route, ViewType } from '@/types'; +import { parseDate } from '@/utils/parse-date'; +import got from '@/utils/got'; +import timezone from '@/utils/timezone'; + +export const route: Route = { + path: '/gerenzhongxin/guba/:uid', + categories: ['finance'], + view: ViewType.Articles, + example: '/eastmoney/gerenzhongxin/guba/2922094262312522', + parameters: { uid: '用户id,即用户主页网址末尾的数字' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['guba.eastmoney.com'], + }, + { + source: ['caifuhao.eastmoney.com'], + }, + { + source: ['i.eastmoney.com/:uid'], + target: '/gerenzhongxin/guba/:uid', + }, + ], + name: '个人中心帖子', + maintainers: ['AwesomeDog'], + handler, +}; + +export async function handler(ctx) { + const uid = ctx.req.param('uid'); + + const url = `https://i.eastmoney.com/api/guba/postCenterList?uid=${uid}&pagenum=1&pagesize=10&type=1&filterType=2&onlyYt=0`; + + const response = await got(url); + const arr = response.data.result; + const nickname = arr[0].post_user.user_nickname; + + const items = arr.map((item) => { + let descriptionContent = item.post_content; + if (item.post_pic_url && item.post_pic_url.length > 0) { + const imagesHTML = item.post_pic_url.map((url: string) => ``).join(''); + descriptionContent += '
' + imagesHTML; + } + + return { + title: item.post_title || `${nickname} 发布了帖子: ${descriptionContent}`, + description: descriptionContent, + pubDate: timezone(parseDate(item.post_publish_time), 8), + link: `https://guba.eastmoney.com/news,${item.post_guba.stockbar_code},${item.post_id}.html`, + author: item.post_user.user_nickname, + }; + }); + + return { + title: `${nickname} 的东财帖子`, + link: `https://i.eastmoney.com/${uid}#guba`, + image: `https://avator.eastmoney.com/qface/${uid}/360`, + item: items, + }; +} diff --git a/lib/routes/eastmoney/gerenzhongxin/trpl.ts b/lib/routes/eastmoney/gerenzhongxin/trpl.ts new file mode 100644 index 000000000..eadcfe389 --- /dev/null +++ b/lib/routes/eastmoney/gerenzhongxin/trpl.ts @@ -0,0 +1,76 @@ +import { Route, ViewType } from '@/types'; +import { parseDate } from '@/utils/parse-date'; +import got from '@/utils/got'; +import timezone from '@/utils/timezone'; +import md5 from '@/utils/md5'; + +export const route: Route = { + path: '/gerenzhongxin/trpl/:uid', + categories: ['finance'], + view: ViewType.Articles, + example: '/eastmoney/gerenzhongxin/trpl/2922094262312522', + parameters: { uid: '用户id,即用户主页网址末尾的数字' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['guba.eastmoney.com'], + }, + { + source: ['caifuhao.eastmoney.com'], + }, + { + source: ['i.eastmoney.com/:uid'], + target: '/gerenzhongxin/trpl/:uid', + }, + ], + name: '个人中心评论', + maintainers: ['AwesomeDog'], + handler, +}; + +export async function handler(ctx) { + const uid = ctx.req.param('uid'); + const url = `https://i.eastmoney.com/api/guba/myreply?pageindex=1&uid=${uid}&checkauth=true`; + + const response = await got(url); + const arr = response.data.result.list; + const nickname = arr[0].reply_user.user_nickname; + + const items = arr.map((item) => { + const linkUrl = `https://guba.eastmoney.com/news,${item.reply_guba.stockbar_code},${item.source_post_id}.html#allReplyList`; + const descriptionContent = ` +

${item.source_post_title}

+
+
+
+

${item.reply_text}

+
+

—— 评论者:${item.reply_user.user_nickname}

+ `; + + const guid: string = 'guid-' + md5(item.reply_text) + `-${item.source_post_id}`; + + return { + title: item.post_title || `${nickname} 发布了评论: ${descriptionContent}`, + description: descriptionContent, + pubDate: timezone(parseDate(item.reply_publish_time), 8), + link: linkUrl, + guid, + author: item.reply_user.user_nickname, + }; + }); + + return { + title: `${nickname} 的东财评论`, + link: `https://i.eastmoney.com/${uid}#trpl`, + image: `https://avator.eastmoney.com/qface/${uid}/360`, + item: items, + }; +}