diff --git a/docs/en/program-update.md b/docs/en/program-update.md index ff3991cc65..30862a4368 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -155,6 +155,18 @@ Refer to [#minecraft](/en/game.html#minecraft) 见 [#playstation](/game.html#playstation) +## QNAP + +### Release Notes + + + +| QTS | QuTS hero | QuTScloud | QuWAN Orchestrator | QES | TAS | AfoBot | +| --- | --------- | --------- | ------------------ | --- | --- | ------ | +| qts | quts_hero | qutscloud | quwan_orchestrator | qes | tas | afobot | + + + ## RSSHub ### New routes diff --git a/docs/program-update.md b/docs/program-update.md index 5d1a62bbd4..67c0698bbf 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -202,6 +202,18 @@ pageClass: routes 见 [#playstation](/game.html#playstation) +## QNAP + +### Release Notes + + + +| QTS | QuTS hero | QuTScloud | QuWAN Orchestrator | QES | TAS | AfoBot | +| --- | --------- | --------- | ------------------ | --- | --- | ------ | +| qts | quts_hero | qutscloud | quwan_orchestrator | qes | tas | afobot | + + + ## Quicker ### 版本更新 diff --git a/lib/router.js b/lib/router.js index a4f597a5ec..2dd1f33236 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3380,4 +3380,7 @@ router.get('/dev.to/top/:period', require('./routes/dev.to/top')); router.get('/gameres/hot', require('./routes/gameres/hot')); router.get('/gameres/list/:id', require('./routes/gameres/list')); +// QNAP +router.get('/qnap/release-notes/:id', require('./routes/qnap/release-notes')); + module.exports = router; diff --git a/lib/routes/qnap/release-notes.js b/lib/routes/qnap/release-notes.js new file mode 100644 index 0000000000..eb0cdd8ed8 --- /dev/null +++ b/lib/routes/qnap/release-notes.js @@ -0,0 +1,51 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.qnap.com'; + const currentUrl = `${rootUrl}/en/release-notes/${ctx.params.id}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + const list = $('.tier1-menu li.active .tier2-menu li .tier3-menu li a') + .slice(0, 20) + .map((_, item) => { + item = $(item); + return { + title: item.text().trim(), + link: `${rootUrl}/en/release-notes/${item.attr('data-os')}/${item.attr('data-version')}/${item.attr('data-build-number')}`, + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const links = item.link.split('/'); + const apiUrl = `${rootUrl}/api/v1/release-notes/${links[4]}?locale=en&version=${links[5]}&build_number=${links[6]}`; + + const detailResponse = await got({ + method: 'get', + url: apiUrl, + }); + + const content = cheerio.load(detailResponse.data.result); + + item.description = content('.content').html(); + item.pubDate = new Date(content('.title-container p').text()).toUTCString(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('.tier1-menu li.active span').eq(0).text()} - QNAP`, + link: currentUrl, + item: items, + }; +};