diff --git a/docs/program-update.md b/docs/program-update.md index 89032a269d..33026565dd 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -34,6 +34,10 @@ pageClass: routes +## CurseForge + + + ## Docker Hub ### 镜像有新 Build diff --git a/lib/router.js b/lib/router.js index 55359d1deb..ea0d5c5a04 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/curseforge/generalfiles.js b/lib/routes/curseforge/generalfiles.js new file mode 100644 index 0000000000..79dc1440ea --- /dev/null +++ b/lib/routes/curseforge/generalfiles.js @@ -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: ` + + + + + + + + + + + +
FileTypeFileNameFileSizeDownload
${$(item) + .find('td.project-file__release-type > span') + .attr('title')}${$(item) + .find('span.table__content.file__name.full') + .text() + .trim()}${$(item) + .find('span.table__content.file__size') + .text() + .trim()}Click Me
`, + link: filePage, + pubDate: new Date( + 1000 * + $(item) + .find('td.project-file__date-uploaded abbr') + .attr('data-epoch') + ).toUTCString(), + })) + .get(), + }; +};