Add appstore/price && Update appstore/update (#482)

This commit is contained in:
Henry Wang
2018-08-17 07:24:52 +01:00
committed by DIYgod
parent e7b77acf8e
commit 2d19cb366e
8 changed files with 98 additions and 5 deletions

View File

@@ -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 主投稿

View File

@@ -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 价格更新(限免) <Author uid="HenryQW"/>
举例: [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
### 番剧

View File

@@ -7,7 +7,7 @@ sidebar: auto
</p>
<h1 align="center" class="logo">RSSHub</h1>
> 🍰 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 <Author uid="cielpy"/>
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 <Author uid="HenryQW"/>
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 typeeither `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 <Author uid="EYHN"/>

View File

@@ -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",

View File

@@ -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'));

43
routes/appstore/price.js Normal file
View File

@@ -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: `<a href="${link}" target="_blank">Go to App Store</a>`,
link,
guid: country + id,
};
item.push(single);
}
ctx.state.data = {
title,
link: url,
item,
};
};

View File

@@ -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],
};

View File

@@ -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"