diff --git a/README.md b/README.md index 8b7ee4e475..b7f5ba63b8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 腾讯云移动直播 SDK - Bugly SDK - fir.im 应用 - - App Store/Mac App Store + - App Store/Mac App Store 应用更新 + - App Store/Mac App Store 价格更新(限免) - bilibili - 番剧 - UP 主投稿 diff --git a/docs/README.md b/docs/README.md index 7f13077013..c4239aa780 100644 --- a/docs/README.md +++ b/docs/README.md @@ -170,6 +170,20 @@ country, App Store 国家,必选,如 QQ 的链接为 https://itunes.apple.co id, App Store app id,必选,如 QQ 的链接为 https://itunes.apple.com/cn/app/qq/id444934666?mt=8,则 id 为 id444934666 +### App Store/Mac App Store 价格更新(限免) + +举例: [https://rsshub.app/appstore/price/cn/mac/id115244347](https://rsshub.app/appstore/price/cn/mac/id115244347) + +路由: `/appstore/price/:country/:type/:id` + +参数: + +country, App Store 国家,必选,如 Squash 的链接为 https://itunes.apple.com/cn/app/id1152443474,则 country 为 cn + +type, App 类型,必选, `iOS` 或 `mac` + +id, App Store app id,必选,如 Squash 的链接为 https://itunes.apple.com/cn/app/id1152443474,则 id 为 id115244347 + ## bilibili ### 番剧 diff --git a/docs/en/README.md b/docs/en/README.md index 24d2c958a6..de3c291d53 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -7,7 +7,7 @@ sidebar: auto

RSSHub

-> 🍰 Everything can be RSS +> 🍰 Everything is RSSible RSSHub is a lightweight and extensible RSS feed aggregator, it's able to generate feeds from pretty much everything. @@ -134,6 +134,32 @@ Parameters: platform | ------- | ------- | ---- | ------- | ------------ | | desktop | android | beta | nightly | android-beta | +### App Store/Mac App Store Updates + +Eg: [https://rsshub.app/appstore/update/us/id697846300](https://rsshub.app/appstore/update/us/id697846300) + +Route: `/appstore/update/:country/:id` + +Parameters: + +country, App Store Country, obtain from the app URL `https://itunes.apple.com/us/app/reeder-3/id697846300?mt=8`, in this case, `us`. + +id, App Store app id, obtain from the app URL `https://itunes.apple.com/us/app/reeder-3/id697846300?mt=8`, in this case, `id697846300`. + +### App Store/Mac App Store Price Drop Alert + +eg: [https://rsshub.app/appstore/price/cn/mac/id115244347](https://rsshub.app/appstore/price/cn/mac/id115244347) + +Route: `/appstore/price/:country/:type/:id` + +Parameters: + +- country, App Store Country, obtain from the app URL https://itunes.apple.com/us/app/id1152443474, in this case, `us`. + +- type, App type,either `iOS` or `mac` + +- id, App Store app id, obtain from the app URL https://itunes.apple.com/cn/app/id1152443474, in this case, `id1152443474`. + ## pixiv ### User Bookmark diff --git a/package.json b/package.json index 1f7bbb40eb..4e4d3db058 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "cheerio": "1.0.0-rc.2", "co-redis": "2.1.1", "crypto": "1.0.1", + "currency-symbol-map": "^4.0.4", "form-data": "^2.3.2", "git-rev-sync": "1.12.0", "googleapis": "32.0.0", diff --git a/router.js b/router.js index 6b106cf6a7..473998afcc 100755 --- a/router.js +++ b/router.js @@ -419,6 +419,7 @@ 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')); // Hopper router.get('/hopper/:from/:to?', require('./routes/hopper/index')); diff --git a/routes/appstore/price.js b/routes/appstore/price.js new file mode 100644 index 0000000000..1786f158ed --- /dev/null +++ b/routes/appstore/price.js @@ -0,0 +1,43 @@ +const axios = require('../../utils/axios'); +const currency = require('currency-symbol-map'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const country = ctx.params.country; + const type = ctx.params.type.toLowerCase() === 'mac' ? 'macapps' : 'apps'; + const id = ctx.params.id.replace('id', ''); + + const url = `https://buster.cheapcharts.de/v1/DetailData.php?&store=itunes&country=${country}&itemType=${type}&idInStore=${id}`; + + const res = await axios({ + method: 'get', + url: url, + headers: { + 'User-Agent': config.ua, + Referer: `http://www.cheapcharts.info/itunes/${country}/apps/detail-view/${id}`, + }, + }); + + const result = res.data.results.apps; + + const item = []; + + const title = `${country === 'cn' ? '限免提醒' : 'Price watcher'}: ${result.title} for ${type === 'macapps' ? 'macOS' : 'iOS'}`; + + const link = `https://itunes.apple.com/${country}/app/id${id}`; + + if (result.priceDropIndicator === -1) { + const single = { + title: `${result.title} is now ${currency(result.currency)}${result.price} `, + description: `Go to App Store`, + link, + guid: country + id, + }; + item.push(single); + } + ctx.state.data = { + title, + link: url, + item, + }; +}; diff --git a/routes/appstore/update.js b/routes/appstore/update.js index ae2a9da81e..9dcf0f4304 100644 --- a/routes/appstore/update.js +++ b/routes/appstore/update.js @@ -19,20 +19,23 @@ module.exports = async (ctx) => { const titleTags = $('h1').attr('class', 'product-header__title'); titleTags.find('span').remove(); + const platform = $('.we-localnav__title__product').text(); + + const title = `${titleTags.text()} 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() + version; - item.description = $('.whats-new__content .we-truncate').text(); + item.title = `${titleTags.text()} ${version}`; + item.description = $('.whats-new__content .we-truncate').html(); item.link = url; item.guid = id + version; }); ctx.state.data = { - title: 'App Store 有 App 更新', + title, link: url, item: [item], }; diff --git a/yarn.lock b/yarn.lock index 73a285c0cd..f481427fee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2118,6 +2118,10 @@ csso@~2.3.1: clap "^1.0.9" source-map "^0.5.3" +currency-symbol-map@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/currency-symbol-map/-/currency-symbol-map-4.0.4.tgz#3cfba625974dd3f86822d327ecbd10248695e95e" + currently-unhandled@^0.4.1: version "0.4.1" resolved "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"