diff --git a/docs/en/README.md b/docs/en/README.md index b82925c184..66cf18b029 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -175,15 +175,15 @@ If no matching results were found, the server returns only a HTTP status code `2 #### App Update - + #### Price Drop - + #### In-App-Purchase Price Drop Alert - + ### F-Droid diff --git a/docs/program-update.md b/docs/program-update.md index c255c9db4d..d1a8db458f 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -14,15 +14,15 @@ pageClass: routes ### 应用更新 - + ### 价格更新(限免) - + ### 内购价格更新(限免) - + ### 每日精品限免 / 促销应用(鲜面连线 by AppSo) diff --git a/lib/router.js b/lib/router.js index 44b3cc6e1f..e9249b06f1 100644 --- a/lib/router.js +++ b/lib/router.js @@ -468,11 +468,11 @@ router.get('/pigtails', require('./routes/pigtails')); router.get('/imuseum/:city/:type?', require('./routes/imuseum')); // AppStore -router.get('/appstore/update/:country/:id', require('./routes/appstore/update')); -router.get('/appstore/price/:country/:type/:id', require('./routes/appstore/price')); -router.get('/appstore/iap/:country/:id', require('./routes/appstore/in-app-purchase')); -router.get('/appstore/xianmian', require('./routes/appstore/xianmian')); -router.get('/appstore/gofans', require('./routes/appstore/gofans')); +router.get('/appstore/update/:country/:id', require('./routes/apple/appstore/update')); +router.get('/appstore/price/:country/:type/:id', require('./routes/apple/appstore/price')); +router.get('/appstore/iap/:country/:id', require('./routes/apple/appstore/in-app-purchase')); +router.get('/appstore/xianmian', require('./routes/apple/appstore/xianmian')); +router.get('/appstore/gofans', require('./routes/apple/appstore/gofans')); // Hopper router.get('/hopper/:lowestOnly/:from/:to?', require('./routes/hopper/index')); diff --git a/lib/routes/appstore/gofans.js b/lib/routes/apple/appstore/gofans.js similarity index 100% rename from lib/routes/appstore/gofans.js rename to lib/routes/apple/appstore/gofans.js diff --git a/lib/routes/appstore/in-app-purchase.js b/lib/routes/apple/appstore/in-app-purchase.js similarity index 95% rename from lib/routes/appstore/in-app-purchase.js rename to lib/routes/apple/appstore/in-app-purchase.js index df597c9609..88674c90d5 100644 --- a/lib/routes/appstore/in-app-purchase.js +++ b/lib/routes/apple/appstore/in-app-purchase.js @@ -5,7 +5,7 @@ const cheerio = require('cheerio'); module.exports = async (ctx) => { const country = ctx.params.country; const id = ctx.params.id; - const link = `https://itunes.apple.com/${country}/app/${id}`; + const link = `https://apps.apple.com/${country}/app/${id}`; const target = url.resolve(link, '?mt=8#see-all/in-app-purchases'); const res = await got.get(target); diff --git a/lib/routes/appstore/price.js b/lib/routes/apple/appstore/price.js similarity index 96% rename from lib/routes/appstore/price.js rename to lib/routes/apple/appstore/price.js index fff8065664..6bcbdbb63c 100644 --- a/lib/routes/appstore/price.js +++ b/lib/routes/apple/appstore/price.js @@ -33,7 +33,7 @@ module.exports = async (ctx) => { const title = `${country === 'cn' ? '限免提醒' : 'Price watcher'}: ${result.title} for ${type === 'macapps' ? 'macOS' : 'iOS'}`; - const link = `https://itunes.apple.com/${country}/app/id${id}`; + const link = `https://apps.apple.com/${country}/app/id${id}`; if (result.priceDropIndicator === -1) { const single = { diff --git a/lib/routes/appstore/update.js b/lib/routes/apple/appstore/update.js similarity index 50% rename from lib/routes/appstore/update.js rename to lib/routes/apple/appstore/update.js index a5a41a8fe5..9777a53a5f 100644 --- a/lib/routes/appstore/update.js +++ b/lib/routes/apple/appstore/update.js @@ -4,7 +4,7 @@ const cheerio = require('cheerio'); module.exports = async (ctx) => { const id = ctx.params.id; const country = ctx.params.country; - const url = `https://itunes.apple.com/${country}/app/${id}`; + const url = `https://apps.apple.com/${country}/app/${id}`; const res = await got.get(url); const $ = cheerio.load(res.data); @@ -13,22 +13,26 @@ module.exports = async (ctx) => { 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 title = `${titleTags.text().trim()} for ${platform === 'App Store' ? 'iOS' : 'macOS'} ${country === 'cn' ? '更新' : 'Update'}`; - const item = {}; - $('.whats-new').each(function() { - const version = $('.whats-new__latest__version') - .text() - .split(' ')[1]; - item.title = `${titleTags.text().trim()} ${version}`; - item.description = $('.whats-new__content .we-truncate').html(); - item.link = url; - item.guid = id + version; - }); + const items = []; + if ($('.whats-new').length > 0) { + $('.whats-new').each(function() { + const version = $('.whats-new__latest__version') + .text() + .split(' ')[1]; + const item = {}; + item.title = `${titleTags.text().trim()} ${version}`; + item.description = $('.whats-new__content .we-truncate').html(); + item.link = url; + item.guid = id + version; + items.push(item); + }); + } ctx.state.data = { title, link: url, - item: [item], + item: items, }; }; diff --git a/lib/routes/appstore/xianmian.js b/lib/routes/apple/appstore/xianmian.js similarity index 100% rename from lib/routes/appstore/xianmian.js rename to lib/routes/apple/appstore/xianmian.js