diff --git a/lib/v2/apple/apps.js b/lib/v2/apple/apps.js new file mode 100644 index 000000000..35ce321e1 --- /dev/null +++ b/lib/v2/apple/apps.js @@ -0,0 +1,36 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { id, country } = ctx.params; + const url = `https://apps.apple.com/${country}/app/${id}`; + + const res = await got(url); + const $ = cheerio.load(res.data); + + const webPlatform = $('.we-localnav__title__product').text(); + + const appData = JSON.parse(Object.values(JSON.parse($('script#shoebox-media-api-cache-apps').text()))[0]); + const appName = appData.d[0].attributes.name; + const platform = Object.values(appData.d[0].attributes.platformAttributes)[0]; // may incldes osx appletvos, ios, etc. + + const items = platform.versionHistory.map((item) => ({ + title: `${appName} ${item.versionDisplay}`, + description: item.releaseNotes?.replace(/\n/g, '
'), + pubDate: parseDate(item.releaseTimestamp), + guid: `apple:apps:update:${country}:${id}:${item.versionDisplay}`, + link: url, + })); + + ctx.state.data = { + title: `${appName} for ${webPlatform === 'App Store' ? 'iOS' : 'macOS'} ${country === 'cn' ? '更新' : 'Update'}`, + description: platform.description.standard?.replace(/\n/g, ' '), + link: url, + item: items, + }; + + ctx.state.json = { + appData, + }; +}; diff --git a/lib/v2/apple/maintainer.js b/lib/v2/apple/maintainer.js index f20b561dc..5c93b9947 100644 --- a/lib/v2/apple/maintainer.js +++ b/lib/v2/apple/maintainer.js @@ -1,3 +1,4 @@ module.exports = { + '/apps/update/:country/:id': ['EkkoG'], '/exchange_repair/:country?': ['metowolf', 'HenryQW', 'kt286'], }; diff --git a/lib/v2/apple/radar.js b/lib/v2/apple/radar.js index 065cd9d3f..0627820d2 100644 --- a/lib/v2/apple/radar.js +++ b/lib/v2/apple/radar.js @@ -1,6 +1,14 @@ module.exports = { 'apple.com': { _name: 'Apple', + apps: [ + { + title: 'App Update', + docs: 'https://docs.rsshub.app/routes/program-update#app-store-mac-app-store', + source: ['/:contry/app/:appSlug/:id', '/:contry/app/:id'], + target: '/appstore/apps/update/:country/:id', + }, + ], support: [ { title: '换和维修扩展计划', diff --git a/lib/v2/apple/router.js b/lib/v2/apple/router.js index 08eee7272..c9a52ef54 100644 --- a/lib/v2/apple/router.js +++ b/lib/v2/apple/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { + router.get('/apps/update/:country/:id', require('./apps')); router.get('/exchange_repair/:country?', require('./exchange_repair')); }; diff --git a/lib/v2/appstore/maintainer.js b/lib/v2/appstore/maintainer.js index 33d8b2e2f..909a4b3d6 100644 --- a/lib/v2/appstore/maintainer.js +++ b/lib/v2/appstore/maintainer.js @@ -1,5 +1,4 @@ module.exports = { - '/update/:country/:id': ['HenryQW'], '/price/:country/:type/:id': ['HenryQW'], '/iap/:country/:id': ['HenryQW'], '/xianmian': ['Andiedie'], diff --git a/lib/v2/appstore/radar.js b/lib/v2/appstore/radar.js index cb0f09751..19c5ad174 100644 --- a/lib/v2/appstore/radar.js +++ b/lib/v2/appstore/radar.js @@ -2,12 +2,6 @@ module.exports = { 'apple.com': { _name: 'Apple', apps: [ - { - title: '应用更新', - docs: 'https://docs.rsshub.app/routes/program-update#app-store-mac-app-store', - source: ['/:contry/app/:id'], - target: '/appstore/update/:country/:id', - }, { title: '价格更新', docs: 'https://docs.rsshub.app/routes/program-update#app-store-mac-app-store', diff --git a/lib/v2/appstore/router.js b/lib/v2/appstore/router.js index 9575545c3..b8076dd66 100644 --- a/lib/v2/appstore/router.js +++ b/lib/v2/appstore/router.js @@ -3,5 +3,4 @@ module.exports = function (router) { router.get('/xianmian', require('./xianmian')); router.get('/iap/:country/:id', require('./in-app-purchase')); router.get('/price/:country/:type/:id', require('./price')); - router.get('/update/:country/:id', require('./update')); }; diff --git a/lib/v2/appstore/update.js b/lib/v2/appstore/update.js deleted file mode 100644 index 7e5fb500c..000000000 --- a/lib/v2/appstore/update.js +++ /dev/null @@ -1,37 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const id = ctx.params.id; - const country = ctx.params.country; - const url = `https://apps.apple.com/${country}/app/${id}`; - - const res = await got.get(url); - const $ = cheerio.load(res.data); - - const titleTags = $('h1').attr('class', 'product-header__title'); - titleTags.find('span').remove(); - const platform = $('.we-localnav__title__product').text(); - - const title = `${titleTags.text().trim()} for ${platform === 'App Store' ? 'iOS' : 'macOS'} ${country === 'cn' ? '更新' : 'Update'}`; - - const items = []; - if ($('.whats-new').length > 0) { - $('.whats-new').each(() => { - const version = $('.whats-new__latest__version').text().split(' ')[1]; - const date = $('.whats-new__content time').attr('aria-label'); - const item = {}; - item.title = `${titleTags.text().trim()} ${version}`; - item.description = $('.whats-new__content .we-truncate').html(); - item.link = url; - item.guid = id + version; - item.pubDate = date; - items.push(item); - }); - } - ctx.state.data = { - title, - link: url, - item: items, - }; -}; diff --git a/website/docs/routes/other.md b/website/docs/routes/other.md index 7dca5e3d3..9c8ae6dfb 100644 --- a/website/docs/routes/other.md +++ b/website/docs/routes/other.md @@ -141,7 +141,7 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store) ### 国家卫健委 - 疫情通报 {#corona-virus-disease-2019-guo-jia-wei-jian-wei-yi-qing-tong-bao} - + ### 财新网 - 新冠肺炎防疫全纪录 {#corona-virus-disease-2019-cai-xin-wang-xin-guan-fei-yan-fang-yi-quan-ji-lu} diff --git a/website/docs/routes/program-update.md b/website/docs/routes/program-update.md index 1515fc1a5..efe6afbf5 100644 --- a/website/docs/routes/program-update.md +++ b/website/docs/routes/program-update.md @@ -59,7 +59,7 @@ The parameters can be extracted from the Release page URL: `https://install.appc ### App Update {#app-store-mac-app-store-app-update} - + ### Price Drop {#app-store-mac-app-store-price-drop} @@ -159,7 +159,7 @@ Language ### 更新日志 {#bugly-sdk-geng-xin-ri-zhi} - + ## Cent Browser {#cent-browser} @@ -295,7 +295,7 @@ Language ### 更新 {#fir.im-ying-yong-geng-xin} - + ## Firefox {#firefox} @@ -463,7 +463,7 @@ Logseq 开发团队已经放弃了 [旧网站](https://logseq.com/blog)。 ### Changelog {#nvidia-web-driver-changelog} - + ## O&O Software {#o-o-software} @@ -769,7 +769,7 @@ Language ### 更新日志 {#teng-xun-yun-yi-dong-zhi-bo-sdk-geng-xin-ri-zhi} - + ## 小米应用商店 {#xiao-mi-ying-yong-shang-dian}