feat: add CurseForge (#2119)

This commit is contained in:
junfengP 2019-05-13 16:33:37 +08:00 committed by DIYgod
parent 745d4eb3f1
commit ac708f2210
3 changed files with 68 additions and 0 deletions

View File

@ -34,6 +34,10 @@ pageClass: routes
<Route author="cielpy" example="/bugly/changelog/1" path="/bugly/changelog/:platform" :paramsDesc="['平台类型, 必选, 1 为 Android, 2 为 iOS']"/>
## CurseForge
<Route name="文件更新" author="junfengP" example="/curseforge/sc2/assets/taylor-mouses-stuff/files" path="/curseforge/:gameid/:catalogid/:projectid/files" :paramsDesc="['游戏名,以`https://www.curseforge.com/sc2/assets/taylor-mouses-stuff/files`为例,`sc2`代表星际2', '分类名,紧跟在游戏名后,如示例中`assets`', '项目名,紧跟在分类名后,如示例中`taylor-mouses-stuff`']"/>
## Docker Hub
### 镜像有新 Build

View File

@ -1360,6 +1360,9 @@ router.get('/manhuadb/comics/:id', require('./routes/manhuadb/comics'));
// 观察者风闻话题
router.get('/guanchazhe/topic/:id', require('./routes/guanchazhe/topic'));
// 通用CurseForge
router.get('/curseforge/:gameid/:catagoryid/:projectid/files', require('./routes/curseforge/generalfiles'));
// 西南财经大学
router.get('/swufe/seie/:type?', require('./routes/universities/swufe/seie'));

View File

@ -0,0 +1,61 @@
const axios = require('../../utils/axios');
const host = 'https://www.curseforge.com';
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const gameid = ctx.params.gameid;
const catagoryid = ctx.params.catagoryid;
const projectid = ctx.params.projectid;
const filePage = host + `/${gameid}/${catagoryid}/${projectid}/files`;
const response = await axios({
method: 'get',
url: filePage,
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('tr.project-file-list__item');
ctx.state.data = {
title: `CurseForge - ${$('h2.name').text()}`,
link: filePage,
description: 'CurseForge文件更新提醒',
item: list
.map((i, item) => ({
title: $(item)
.find('span.table__content.file__name.full')
.text()
.trim(),
description: `<table>
<tr>
<td>FileType</td>
<td>FileName</td>
<td>FileSize</td>
<td>Download</td></tr>
<tr>
<td>${$(item)
.find('td.project-file__release-type > span')
.attr('title')}</td>
<td>${$(item)
.find('span.table__content.file__name.full')
.text()
.trim()}</td>
<td>${$(item)
.find('span.table__content.file__size')
.text()
.trim()}</td>
<td><a href="${host +
$(item)
.find('td.project-file__actions a')
.attr('href')}">Click Me</a></td>
</tr>
</table>`,
link: filePage,
pubDate: new Date(
1000 *
$(item)
.find('td.project-file__date-uploaded abbr')
.attr('data-epoch')
).toUTCString(),
}))
.get(),
};
};