feat(route): recover gofans (#14183)

This commit is contained in:
Tony
2024-01-05 02:15:56 +08:00
committed by GitHub
parent 9af13494c3
commit 91ce25bcff
6 changed files with 73 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const { join } = require('path');
module.exports = async (ctx) => {
const { kind = '' } = ctx.params;
const baseUrl = 'https://gofans.cn';
const { data: response } = await got('https://api.gofans.cn/v1/web/app_records', {
headers: {
origin: baseUrl,
},
searchParams: {
limit: 20,
kind: kind && (kind === 'macos' ? 1 : 2),
page: 1,
},
});
const items = response.data.map((item) => ({
title: `「${item.price === '0.00' ? '免费' : '降价'}」-「${item.kind === 1 ? 'macOS' : 'iOS'}」${item.name}`,
description: art(join(__dirname, 'templates/description.art'), {
icon: item.icon,
originalPrice: item.original_price,
price: item.price,
kind: item.kind,
description: item.description.replaceAll('\n', '<br>'),
}),
pubDate: parseDate(item.updated_at, 'X'),
link: new URL(`/app/${item.uuid}`, baseUrl).href,
category: item.primary_genre_name,
}));
ctx.state.data = {
title: '最新限免 / 促销应用',
link: baseUrl,
description: 'GoFans:最新限免 / 促销应用',
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:kind?': ['HenryQW'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'gofans.cn': {
_name: 'GoFans',
'.': [
{
title: '最新限免 / 促销应用',
docs: 'https://docs.rsshub.app/program-update#gofans',
source: ['/limited/:kind?', '/'],
target: (params) => `/gofans${(params.kind && (params.kind === 'macos' ? '/macos' : '/ios')) || ''}`,
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:kind?', require('./index'));
};
+7
View File
@@ -0,0 +1,7 @@
<img src="{{ icon }}">
<br>
原价:¥{{ originalPrice }} -> 现价:¥{{ price }}
<br>
平台:{{ kind === 1 ? 'macOS' : 'iOS' }}
<br/>
{{@ description }}
+6
View File
@@ -266,6 +266,12 @@ Need to configure `CIVITAI_COOKIE` to obtain image information of NSFW models.
<Route author="nczitzk" example="/fosshub/qBittorrent" path="/fosshub/:id" paramsDesc={['Software id, can be found in URL']} />
## GoFans {#gofans}
### 最新限免 / 促销应用 {#gofans-zui-xin-xian-mian-cu-xiao-ying-yong}
<Route author="HenryQW" example="/gofans" path="/gofans/:kind?" paramsDesc={['Platform, either `macos` or `ios`, empty means both (default)']} radar="1" />
## Greasy Fork {#greasy-fork}
### Script Update {#greasy-fork-script-update}