mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-21 12:49:53 +08:00
fix(route): Apple App Store platform (#13420)
* fix(route): Apple App Store platform * Update website/docs/routes/program-update.md ---------
This commit is contained in:
+27
-12
@@ -4,30 +4,45 @@ 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 limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 100;
|
||||
|
||||
const res = await got(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
const rootUrl = 'https://apps.apple.com';
|
||||
const currentUrl = new URL(`${country}/app/${id}`, rootUrl).href;
|
||||
|
||||
const webPlatform = $('.we-localnav__title__product').text();
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const webPlatform = $('meta[property="og:site_name"]').prop('content');
|
||||
const subtitle = $('h2.whats-new__headline').text() || "What's New";
|
||||
|
||||
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 attributes = appData.d[0].attributes;
|
||||
const appName = attributes.name;
|
||||
const artistName = attributes.artistName;
|
||||
const platform = Object.values(attributes.platformAttributes)[0]; // may incldes osx appletvos, ios, etc.
|
||||
|
||||
const items = platform.versionHistory.map((item) => ({
|
||||
const items = platform.versionHistory.slice(0, limit).map((item) => ({
|
||||
title: `${appName} ${item.versionDisplay}`,
|
||||
link: currentUrl,
|
||||
description: item.releaseNotes?.replace(/\n/g, '<br>'),
|
||||
pubDate: parseDate(item.releaseTimestamp),
|
||||
guid: `apple:apps:update:${country}:${id}:${item.versionDisplay}`,
|
||||
link: url,
|
||||
pubDate: parseDate(item.releaseTimestamp),
|
||||
}));
|
||||
|
||||
const icon = new URL('favicon.ico', rootUrl).href;
|
||||
|
||||
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,
|
||||
title: `${appName} for ${/^App/.test(webPlatform) ? 'iOS' : 'macOS'} ${subtitle}`,
|
||||
link: currentUrl,
|
||||
description: platform.description.standard?.replace(/\n/g, ' '),
|
||||
language: $('html').prop('lang'),
|
||||
image: $('meta[property="og:image"]').prop('content'),
|
||||
icon,
|
||||
logo: icon,
|
||||
subtitle: appName,
|
||||
author: artistName,
|
||||
};
|
||||
|
||||
ctx.state.json = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
'/apps/update/:country/:id': ['EkkoG'],
|
||||
'/apps/update/:country/:id': ['EkkoG', 'nczitzk'],
|
||||
'/exchange_repair/:country?': ['metowolf', 'HenryQW', 'kt286'],
|
||||
};
|
||||
|
||||
@@ -4,9 +4,9 @@ module.exports = {
|
||||
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',
|
||||
docs: 'https://docs.rsshub.app/routes/program-update#app-store-mac-app-store-app-update',
|
||||
source: ['/:country/app/:appSlug/:id', '/:country/app/:id'],
|
||||
target: '/apple/apps/update/:country/:id',
|
||||
},
|
||||
],
|
||||
support: [
|
||||
|
||||
@@ -59,7 +59,15 @@ The parameters can be extracted from the Release page URL: `https://install.appc
|
||||
|
||||
### App Update {#app-store-mac-app-store-app-update}
|
||||
|
||||
<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"/>
|
||||
<Route author="EkkoG nczitzk" example="/apple/apps/update/us/id408709785" path="/apple/apps/update/:country/:id" paramsDesc={['App Store Country, obtain from the app URL, see below', 'App id, obtain from the app URL']} radar="1" rssbud="1">
|
||||
|
||||
:::tip
|
||||
|
||||
For example, the URL of [GarageBand](https://apps.apple.com/us/app/messages/id408709785) in the App Store is <https://apps.apple.com/us/app/messages/id408709785>. In this case, the `App Store Country` parameter for the route is `us`, and the `App id` parameter is `id1146560473`. So the route should be [`/apple/apps/update/us/id408709785`](https://rsshub.app/apple/apps/update/us/id408709785).
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
### Price Drop {#app-store-mac-app-store-price-drop}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user