diff --git a/README.md b/README.md index c10d726..3afe9f1 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Available options/variables and their default values: | EG_PASSWORD | | Epic Games password for login. Overrides PASSWORD. | | EG_OTPKEY | | Epic Games MFA OTP key. | | EG_PARENTALPIN | | Epic Games Parental Controls PIN. | +| EG_COUNTRY | US | Epic Games [country of account](https://www.epicgames.com/account/personal). Set to avoid unavailable-in-region. | | PG_EMAIL | | Prime Gaming email for login. Overrides EMAIL. | | PG_PASSWORD | | Prime Gaming password for login. Overrides PASSWORD. | | PG_OTPKEY | | Prime Gaming MFA OTP key. | diff --git a/config.js b/config.js index 33016ca..ef3ed3f 100644 --- a/config.js +++ b/config.js @@ -27,6 +27,7 @@ export const cfg = { eg_password: process.env.EG_PASSWORD || process.env.PASSWORD, eg_otpkey: process.env.EG_OTPKEY, eg_parentalpin: process.env.EG_PARENTALPIN, + eg_country: process.env.EG_COUNTRY || 'US', // This should fit your account's country since sometimes there are replacements for games that are unavailable-in-region. See country/region under https://www.epicgames.com/account/personal and use its two-letter country code. // auth prime-gaming pg_email: process.env.PG_EMAIL || process.env.EMAIL, pg_password: process.env.PG_PASSWORD || process.env.PASSWORD, diff --git a/epic-games.js b/epic-games.js index 7b2d879..a9e2c27 100644 --- a/epic-games.js +++ b/epic-games.js @@ -17,7 +17,7 @@ handleSIGINT(); // get current promotionalOffers from json instead of checking the website // process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // otherwise got UNABLE_TO_GET_ISSUER_CERT_LOCALLY -const promoJson = await (await fetch('https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions')).json(); // ?locale=en-US +const promoJson = await (await fetch(`https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions?country=${cfg.eg_country}`)).json(); // ?locale=en-US const currentGames = promoJson.data.Catalog.searchStore.elements.filter(e => e.promotions?.promotionalOffers?.length); const gameURL = e => `https://store.epicgames.com/p/${e.catalogNs.mappings[0].pageSlug}`; // gameURL(e.urlSlug) is wrong and leads to 404! console.log('Free games:', currentGames.map(e => `${e.title} - ${gameURL(e)}`));