parent
fe3a03be13
commit
22bd174f2e
|
|
@ -10,27 +10,47 @@ module.exports = async (ctx) => {
|
|||
|
||||
const res = await got.get(target);
|
||||
const $ = cheerio.load(res.data);
|
||||
const lang = $('html').attr('lang');
|
||||
|
||||
const data = JSON.parse($('#shoebox-ember-data-store')[0].firstChild.data);
|
||||
const attributes = data.data.attributes;
|
||||
const apiResponse = (
|
||||
await got({
|
||||
method: 'get',
|
||||
url: `https://amp-api.apps.apple.com/v1/catalog/${country}/apps/${id.replace(
|
||||
'id',
|
||||
''
|
||||
)}?platform=web&additionalPlatforms=appletv%2Cipad%2Ciphone%2Cmac&extend=description%2CdeveloperInfo%2CeditorialVideo%2Ceula%2CfileSizeByDevice%2CmessagesScreenshots%2CprivacyPolicyUrl%2CprivacyPolicyText%2CpromotionalText%2CscreenshotsByType%2CsupportURLForLanguage%2CversionHistory%2CvideoPreviewsByType%2CwebsiteUrl&include=genres%2Cdeveloper%2Creviews%2Cmerchandised-in-apps%2Ccustomers-also-bought-apps%2Cdeveloper-other-apps%2Capp-bundles%2Ctop-in-apps%2Ceula&l=${lang}`,
|
||||
headers: {
|
||||
authorization:
|
||||
'Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ.eyJpc3MiOiJBTVBXZWJQbGF5IiwiaWF0IjoxNTc0MTk3NDA3LCJleHAiOjE1ODk3NDk0MDd9.ael_GP97O4fyXJuQAQlmC7ieY-t-OOGFwtXShhVA6m_p9Sq03D-_FiUKSfZ2iXGob3vPFnDe0s_OKI3Tg7KVaA',
|
||||
authority: 'amp-api.apps.apple.com',
|
||||
referer: target,
|
||||
},
|
||||
})
|
||||
).data.data[0];
|
||||
|
||||
const attributes = apiResponse.attributes;
|
||||
const titleTemp = attributes.name;
|
||||
const platform = attributes.kind === 'iosSoftware' ? 'iOS' : 'macOS';
|
||||
|
||||
const platform = attributes.deviceFamilies.includes('mac') ? 'macOS' : 'iOS';
|
||||
let title;
|
||||
let item = [];
|
||||
if (attributes.hasInAppPurchases) {
|
||||
|
||||
const iap = apiResponse.relationships['merchandised-in-apps'].data;
|
||||
if (iap) {
|
||||
title = `${country === 'cn' ? '内购限免提醒' : 'IAP price watcher'}: ${titleTemp} for ${platform}`;
|
||||
const list = data.included.filter((e) => e.type === 'product/app/in-app');
|
||||
item = list.map((e) => {
|
||||
const title = `${e.attributes.name} is now ${e.attributes.price}`;
|
||||
return {
|
||||
link,
|
||||
guid: title,
|
||||
title,
|
||||
pubDate: new Date(Date.now()).toUTCString(),
|
||||
};
|
||||
});
|
||||
} else {
|
||||
title = `${titleTemp} for ${platform} ${country === 'cn' ? ' 不包含内购项目' : 'has no IAP items'}`;
|
||||
|
||||
item = iap
|
||||
.filter((e) => e.attributes.isMerchandisedEnabled)
|
||||
.map((e) => {
|
||||
const title = `${e.attributes.name} is now ${e.attributes.offers[0].priceFormatted}`;
|
||||
return {
|
||||
link,
|
||||
guid: e.attributes.url,
|
||||
description: e.attributes.description.standard,
|
||||
title,
|
||||
pubDate: new Date().toUTCString(),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ module.exports = async (ctx) => {
|
|||
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('section.as-columns').get();
|
||||
const list = $('section.as-columns')
|
||||
.get()
|
||||
.slice(0, 5);
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
|
|
@ -40,7 +42,7 @@ module.exports = async (ctx) => {
|
|||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Apple --- ${$('.main>.richText h1').text()}`,
|
||||
title: `Apple - ${$('.main>.richText h1').text()}`,
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue