diff --git a/assets/radar-rules.js b/assets/radar-rules.js index afd2cf6e0..29235c10e 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -546,4 +546,15 @@ }, ], }, + 'epicgames.com': { + _name: 'Epic Games', + www: [ + { + title: '每周免费游戏', + docs: 'https://docs.rsshub.app/game.html#epicgames-freegame', + source: '/:collection', + target: '/epicgames/:collection', + }, + ], + }, }); diff --git a/lib/routes/epicgames/index.js b/lib/routes/epicgames/index.js index d5b61db44..5e113a5d6 100644 --- a/lib/routes/epicgames/index.js +++ b/lib/routes/epicgames/index.js @@ -1,3 +1,4 @@ +const logger = require('@/utils/logger'); const got = require('@/utils/got'); const supportedList = require('./supportedList'); @@ -32,35 +33,40 @@ module.exports = async (ctx) => { const out = new Array(); let notHaveImageUrl = true; data.Catalog.catalogOffers.elements.map((element) => { - if (element.promotions.promotionalOffers.length !== 0) { - element.promotions.promotionalOffers.forEach((isPromotionalOffer) => { - if (isPromotionalOffer.promotionalOffers.length !== 0) { - isPromotionalOffer.promotionalOffers.forEach((havePromotionalOffer) => { - if (havePromotionalOffer.discountSetting.discountType === 'PERCENTAGE' && havePromotionalOffer.discountSetting.discountPercentage === 0) { - item = { - title: element.title, - link: `https://www.epicgames.com/store/zh-CN/product/${element.productSlug}`, - pubDate: new Date(havePromotionalOffer.startDate).toUTCString(), - }; - } - if (element.keyImages.length !== 0) { - element.keyImages.forEach((imageUrl) => { - if (imageUrl.type === 'DieselStoreFrontWide') { - item.description = `${element.description}
`; - notHaveImageUrl = false; - } - }); - } - if (notHaveImageUrl) { - item.description = element.description; - } - }); - } - }); - out.push(item); - item = {}; + try { + if (element.promotions.promotionalOffers.length !== 0) { + element.promotions.promotionalOffers.forEach((isPromotionalOffer) => { + if (isPromotionalOffer.promotionalOffers.length !== 0) { + isPromotionalOffer.promotionalOffers.forEach((havePromotionalOffer) => { + if (havePromotionalOffer.discountSetting.discountType === 'PERCENTAGE' && havePromotionalOffer.discountSetting.discountPercentage === 0) { + item = { + title: element.title, + link: `https://www.epicgames.com/store/zh-CN/product/${element.productSlug}`, + pubDate: new Date(havePromotionalOffer.startDate).toUTCString(), + }; + } + if (element.keyImages.length !== 0) { + element.keyImages.forEach((imageUrl) => { + if (imageUrl.type === 'DieselStoreFrontWide') { + item.description = `${element.description}
`; + notHaveImageUrl = false; + } + }); + } + if (notHaveImageUrl) { + item.description = element.description; + } + }); + } + }); + out.push(item); + item = {}; + } + return true; + } catch (warn) { + logger.warn(element.title + '\t==> Parse Error Info:\n' + warn); + return false; } - return true; }); // out.pop(undefined);