feat(route): add MacWk (#7833)

This commit is contained in:
VJ
2021-08-12 14:03:54 +08:00
committed by GitHub
parent c412846dc0
commit c69ca86d03
4 changed files with 53 additions and 0 deletions

View File

@@ -3041,6 +3041,17 @@
},
],
},
'macwk.com': {
_name: 'MacWk',
'.': [
{
title: '应用更新',
docs: 'https://docs.rsshub.app/program-update.html#macwk',
source: '/soft/:name',
target: '/macwk/soft/:name' ,
},
],
},
'zyshow.net': {
www: [
{

View File

@@ -236,6 +236,12 @@ pageClass: routes
<Route author="HXHL" example="/macked/app/cleanmymac-x" path="/macked/app/:name" :paramsDesc="['应用名, 可在应用页 URL 中找到']"/>
## MacWk
### 应用更新
<Route author="f48vj" example="/macwk/soft/sublime-text" path="/macwk/soft/:name" :paramsDesc="['应用名, 可在应用页 URL 中找到']" radar="1" rssbud="1"/>
## ManicTime
<Route author="nczitzk" example="/manictime/releases" path="/manictime/releases"/>

View File

@@ -4140,6 +4140,9 @@ router.get('/caus/:category?', require('./routes/caus'));
// 摩点
router.get('/modian/zhongchou/:category?/:sort?/:status?', require('./routes/modian/zhongchou'));
// MacWk
router.get('/macwk/soft/:name', require('./routes/macwk/soft'));
// 世界计划 多彩舞台 feat.初音未来 (ProjectSekai)
router.get('/pjsk/news', require('./routes/pjsk/news'));
@@ -4155,4 +4158,5 @@ router.get('/tanchinese/:category?', require('./routes/tanchinese'));
// Harvard
router.get('/harvard/health/blog', require('./routes/universities/harvard/health/blog'));
module.exports = router;

32
lib/routes/macwk/soft.js Normal file
View File

@@ -0,0 +1,32 @@
const got = require('@/utils/got');
const queryString = require('query-string');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const name = ctx.params.name;
const url = `https://api.macwk.com/api/items/soft?${queryString.stringify({
'filter[slug][eq]': name,
fields: 'id,title,description',
})}`;
const res = await got.get(url);
const data = res.data.data[0];
const versionsRes = await got.get(
`https://api.macwk.com/api/items/soft_version?${queryString.stringify({
'filter[softid][eq]': data.id,
})}`
);
const items = versionsRes.data.data.map((item) => ({
title: `${data.title} ${item.version}`,
pubDate: parseDate(item.created_on, 'YYYY/MM/DD HH:mm:ss'),
description: item.download.reduce((desc, download) => `${desc}<a href="${download.url}">${download.name}</a>${download.password ? `<p>密码:${download.password}</p>` : ''}<br>`, ''),
link: `https://macwk.com/soft/${name}`,
guid: `${name} ${item.version}`,
}));
ctx.state.data = {
title: `${data.title} 的软件更新`,
link: `https://macwk.com/soft/${name}`,
description: data.description,
item: items,
};
};