From f4ec71508f6682da4a57eddafcc07b8289e8316f Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 11 Jul 2023 04:27:20 +1100 Subject: [PATCH] feat(route): add macupdate (#12774) --- docs/en/program-update.md | 8 ++++++- docs/program-update.md | 12 +++++++--- lib/v2/macupdate/app.js | 43 ++++++++++++++++++++++++++++++++++ lib/v2/macupdate/maintainer.js | 3 +++ lib/v2/macupdate/radar.js | 13 ++++++++++ lib/v2/macupdate/router.js | 3 +++ 6 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 lib/v2/macupdate/app.js create mode 100644 lib/v2/macupdate/maintainer.js create mode 100644 lib/v2/macupdate/radar.js create mode 100644 lib/v2/macupdate/router.js diff --git a/docs/en/program-update.md b/docs/en/program-update.md index a03e50d20..a0ecbb7e2 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -329,7 +329,13 @@ Please use instead. ### APP Update - + + +## MacUpdate + +### Update + + ## ManicTime diff --git a/docs/program-update.md b/docs/program-update.md index 90853eec8..ad0a88f4f 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -348,7 +348,7 @@ pageClass: routes ### 苹果固件更新 - IPSWs/OTAs 版本 - + ## Logseq @@ -363,11 +363,17 @@ Logseq 开发团队已经放弃了 [旧网站](https://logseq.com/blog)。 +## MacUpdate + +### 更新 + + + ## MacWk ### 应用更新 - + ## ManicTime @@ -381,7 +387,7 @@ Logseq 开发团队已经放弃了 [旧网站](https://logseq.com/blog)。 ### 外接程序更新 - + ## Microsoft Store diff --git a/lib/v2/macupdate/app.js b/lib/v2/macupdate/app.js new file mode 100644 index 000000000..9260f4b11 --- /dev/null +++ b/lib/v2/macupdate/app.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { appId, appSlug } = ctx.params; + const baseUrl = 'https://www.macupdate.com'; + const link = `${baseUrl}/app/mac/${appId}${appSlug ? `/${appSlug}` : ''}`; + + const { data: response } = await got(link); + const $ = cheerio.load(response); + + const nextData = JSON.parse($('#__NEXT_DATA__').text()); + + const { + asPath, + appData: { data: appData }, + } = nextData.props.initialProps.pageProps; + + const item = { + title: `${appData.title} ${appData.version}`, + description: appData.release_notes, + pubDate: parseDate(appData.date.timestamp, 'X'), + link: `${baseUrl}${asPath}`, + guid: `macupdate/app/${appId}/${appData.version}`, + category: [appData.category.name, appData.subcategory?.name], + author: appData.developer.name, + }; + + ctx.state.data = { + title: appData.title, + description: appData.description, + link: `${baseUrl}${asPath}`, + logo: appData.logo.source, + icon: appData.logo.source, + item: [item], + language: 'en', + }; + + ctx.state.json = { + pageProps: nextData.props.initialProps.pageProps, + }; +}; diff --git a/lib/v2/macupdate/maintainer.js b/lib/v2/macupdate/maintainer.js new file mode 100644 index 000000000..f280febe0 --- /dev/null +++ b/lib/v2/macupdate/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/app/:appId/:appSlug?': ['TonyRL'], +}; diff --git a/lib/v2/macupdate/radar.js b/lib/v2/macupdate/radar.js new file mode 100644 index 000000000..65e9e21d3 --- /dev/null +++ b/lib/v2/macupdate/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'macupdate.com': { + _name: 'MacUpdate', + '.': [ + { + title: '更新', + docs: 'https://docs.rsshub.app/program-update.html#macupdate', + source: ['/app/mac/:appId/:appSlug'], + target: '/macupdate/app/:appId/:appSlug?', + }, + ], + }, +}; diff --git a/lib/v2/macupdate/router.js b/lib/v2/macupdate/router.js new file mode 100644 index 000000000..427451bd7 --- /dev/null +++ b/lib/v2/macupdate/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/app/:appId/:appSlug?', require('./app')); +};