From 58cce2282dff30901ced35fa2d836b9eaf69c47c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AA=92=E6=81=AF=E5=BE=97=E9=B1=BC?= <39975240+zhixideyu@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:46:22 +0800 Subject: [PATCH] feat(route): add appstare (#17348) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 新增appstare * 完善 * fix: typo --------- Co-authored-by: 张凯龙 --- lib/routes/appstare/comments.ts | 57 ++++++++++++++++++++++++++++++++ lib/routes/appstare/namespace.ts | 6 ++++ 2 files changed, 63 insertions(+) create mode 100644 lib/routes/appstare/comments.ts create mode 100644 lib/routes/appstare/namespace.ts diff --git a/lib/routes/appstare/comments.ts b/lib/routes/appstare/comments.ts new file mode 100644 index 000000000..8db1faf2f --- /dev/null +++ b/lib/routes/appstare/comments.ts @@ -0,0 +1,57 @@ +import { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; + +export const handler = async (ctx) => { + const country = ctx.req.param('country'); + const appid = ctx.req.param('appid'); + const url = `https://monitor.appstare.net/spider/appComments?country=${country}&appId=${appid}`; + const data = await ofetch(url); + + const items = data.map((item) => ({ + title: item.title, + description: ` +
${'⭐️'.repeat(Math.floor(item.rating))}
+

${item.review}

+ `, + pubDate: new Date(item.date).toUTCString(), + })); + + const link = `https://appstare.net/data/app/comment/${appid}/${country}`; + + return { + title: 'App Comments', + appID: appid, + country, + item: items, + link, + allowEmpty: true, + }; +}; + +export const route: Route = { + path: '/comments/:country/:appid', + name: 'Comments', + url: 'appstare.net/', + example: '/appstare/comments/cn/989673964', + maintainers: ['zhixideyu'], + handler, + parameters: { + country: 'App Store country code, e.g., US, CN', + appid: 'Unique App Store application identifier (app id)', + }, + categories: ['program-update'], + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['appstare.net/'], + }, + ], + description: 'Retrieve only the comments of the app from the past 7 days.', +}; diff --git a/lib/routes/appstare/namespace.ts b/lib/routes/appstare/namespace.ts new file mode 100644 index 000000000..3efc0382b --- /dev/null +++ b/lib/routes/appstare/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'AppStare', + url: 'appstare.net', +};