fix(route): appstore (#13357)

* fix(route): appstore

update author github id
refs: #472

* fix: apps without changelog
This commit is contained in:
Tony 2023-09-22 04:54:19 +08:00 committed by GitHub
parent eb1a40aa88
commit 217b0e9d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 52 additions and 51 deletions

36
lib/v2/apple/apps.js Normal file
View File

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

View File

@ -1,3 +1,4 @@
module.exports = {
'/apps/update/:country/:id': ['EkkoG'],
'/exchange_repair/:country?': ['metowolf', 'HenryQW', 'kt286'],
};

View File

@ -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: '换和维修扩展计划',

View File

@ -1,3 +1,4 @@
module.exports = function (router) {
router.get('/apps/update/:country/:id', require('./apps'));
router.get('/exchange_repair/:country?', require('./exchange_repair'));
};

View File

@ -1,5 +1,4 @@
module.exports = {
'/update/:country/:id': ['HenryQW'],
'/price/:country/:type/:id': ['HenryQW'],
'/iap/:country/:id': ['HenryQW'],
'/xianmian': ['Andiedie'],

View File

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

View File

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

View File

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

View File

@ -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}
<Route author="Cielpy DIYgod" example="/coronavirus/nhc" path="/coronavirus/nhc"/>
<Route author="EkkoG DIYgod" example="/coronavirus/nhc" path="/coronavirus/nhc"/>
### 财新网 - 新冠肺炎防疫全纪录 {#corona-virus-disease-2019-cai-xin-wang-xin-guan-fei-yan-fang-yi-quan-ji-lu}

View File

@ -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}
<Route author="cielpy" example="/appstore/update/us/id697846300" path="/appstore/update/:country/:id" paramsDesc={['App Store Country, obtain from the app URL `https://apps.apple.com/us/app/reeder-3/id697846300?mt=8`, in this case, `us`', 'App Store app id, obtain from the app URL `https://apps.apple.com/us/app/reeder-3/id697846300?mt=8`, in this case, `id697846300`']} />
<Route author="EkkoG" example="/apple/apps/update/us/id1529445840" path="/apple/apps/update/:country/:id" paramsDesc={['App Store Country, obtain from the app URL `https://apps.apple.com/us/app/apple-store/id375380948`, in this case, `us`', 'App Store app id, obtain from the app URL `https://apps.apple.com/us/app/apple-store/id375380948`, in this case, `id375380948`']} radar="1"/>
### Price Drop {#app-store-mac-app-store-price-drop}
@ -159,7 +159,7 @@ Language
### 更新日志 {#bugly-sdk-geng-xin-ri-zhi}
<Route author="cielpy" example="/bugly/changelog/1" path="/bugly/changelog/:platform" paramsDesc={['平台类型, 必选, 1 Android, 2 iOS']}/>
<Route author="EkkoG" example="/bugly/changelog/1" path="/bugly/changelog/:platform" paramsDesc={['平台类型, 必选, 1 Android, 2 iOS']}/>
## Cent Browser {#cent-browser}
@ -295,7 +295,7 @@ Language
### 更新 {#fir.im-ying-yong-geng-xin}
<Route author="cielpy" example="/fir/update/xcz" path="/fir/update/:id" paramsDesc={['fir app id, 必选, fir 生成的链接地址为 https://fir.im/xcz, id `xcz`']}/>
<Route author="EkkoG" example="/fir/update/xcz" path="/fir/update/:id" paramsDesc={['fir app id, 必选, fir 生成的链接地址为 https://fir.im/xcz, id `xcz`']}/>
## Firefox {#firefox}
@ -463,7 +463,7 @@ Logseq 开发团队已经放弃了 [旧网站](https://logseq.com/blog)。
### Changelog {#nvidia-web-driver-changelog}
<Route author="cielpy" example="/nvidia/webdriverupdate" path="/nvidia/webdriverupdate"/>
<Route author="EkkoG" example="/nvidia/webdriverupdate" path="/nvidia/webdriverupdate"/>
## O&O Software {#o-o-software}
@ -769,7 +769,7 @@ Language
### 更新日志 {#teng-xun-yun-yi-dong-zhi-bo-sdk-geng-xin-ri-zhi}
<Route author="cielpy" example="/qcloud/mlvb/changelog" path="/qcloud/mlvb/changelog"/>
<Route author="EkkoG" example="/qcloud/mlvb/changelog" path="/qcloud/mlvb/changelog"/>
## 小米应用商店 {#xiao-mi-ying-yong-shang-dian}