fix(route): appstore refactor to V2 (#9177)

* fix(route): appstore refactor to V2

* fix(route): add radar.js

* fix: remove legacy url.resolve
This commit is contained in:
Fatpandac 2022-02-25 00:14:13 +08:00 committed by GitHub
parent 9cb8d5053c
commit 77f3e710fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 12 deletions

View File

@ -488,13 +488,6 @@ router.get('/nvidia/webdriverupdate', lazyloadRouteHandler('./routes/nvidia/webd
// 每日环球展览 iMuseum
router.get('/imuseum/:city/:type?', lazyloadRouteHandler('./routes/imuseum'));
// AppStore
router.get('/appstore/update/:country/:id', lazyloadRouteHandler('./routes/apple/appstore/update'));
router.get('/appstore/price/:country/:type/:id', lazyloadRouteHandler('./routes/apple/appstore/price'));
router.get('/appstore/iap/:country/:id', lazyloadRouteHandler('./routes/apple/appstore/in-app-purchase'));
router.get('/appstore/xianmian', lazyloadRouteHandler('./routes/apple/appstore/xianmian'));
router.get('/appstore/gofans', lazyloadRouteHandler('./routes/apple/appstore/gofans'));
// Hopper
router.get('/hopper/:lowestOnly/:from/:to?', lazyloadRouteHandler('./routes/hopper/index'));

View File

@ -1,5 +1,5 @@
const got = require('@/utils/got');
const url = require('url');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const prefix = 'https://gofans.cn/app/';
@ -27,8 +27,8 @@ module.exports = async (ctx) => {
<br/>
${item.description}
`,
pubDate: new Date(item.updated_at * 1000).toUTCString(),
link: url.resolve(prefix, item.uuid),
pubDate: parseDate(item.updated_at * 1000),
link: new URL(item.uuid, prefix),
})),
};
};

View File

@ -0,0 +1,7 @@
module.exports = {
'/update/:country/:id': ['HenryQW'],
'/price/:country/:type/:id': ['HenryQW'],
'/iap/:country/:id': ['HenryQW'],
'/xianmian': ['Andiedie'],
'/gofans': ['HenryQW'],
};

41
lib/v2/appstore/radar.js Normal file
View File

@ -0,0 +1,41 @@
module.exports = {
'apple.com': {
_name: 'Apple',
apps: [
{
title: '应用更新',
docs: 'https://docs.rsshub.app/program-update.html#app-store-mac-app-store',
source: ['/:contry/app/:id'],
target: '/appstore/update/:country/:id',
},
{
title: '价格更新',
docs: 'https://docs.rsshub.app/program-update.html#app-store-mac-app-store',
source: ['/'],
target: '/appstore/price/:country/:type/:id',
},
],
},
'app.so': {
_name: '鲜面连线',
'.': [
{
title: '限免应用',
docs: 'https://docs.rsshub.app/program-update.html#app-store-mac-app-store',
source: ['/xianmian'],
target: '/appstore/xianmian',
},
],
},
'gofans.cn': {
_name: 'GoFans',
'.': [
{
title: '最新限免',
docs: 'https://docs.rsshub.app/program-update.html#app-store-mac-app-store',
source: ['/'],
target: '/appstore/gofans',
},
],
},
};

View File

@ -0,0 +1,7 @@
module.exports = function (router) {
router.get('/gofans', require('./gofans'));
router.get('/xianmian', require('./xianmian'));
router.get('/iap/:country/:id', require('./in-app-purchase'));
router.get('/price/:country/:type/:id', require('./price'));
router.get('/update/:country/:id', require('./update'));
};

View File

@ -1,9 +1,10 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const {
data: { objects: data },
} = await got.get('http://app.so/api/v5/appso/discount/?platform=web&limit=10');
} = await got.get('https://app.so/api/v5/appso/discount/?platform=web&limit=10');
ctx.state.data = {
title: '每日精品限免 / 促销应用',
@ -20,7 +21,7 @@ module.exports = async (ctx) => {
<br/>
${item.content}
`,
pubDate: new Date(item.updated_at * 1000).toUTCString(),
pubDate: parseDate(item.updated_at * 1000),
link: item.app.download_link[0].link,
})),
};