eg: claim mobile games, closes #474

This commit is contained in:
Ralf Vogler 2025-06-05 18:08:14 +02:00
parent 0890a7a073
commit ba5e51f529
3 changed files with 66 additions and 0 deletions

View file

@ -34,6 +34,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_mobile: process.env.EG_MOBILE != '0', // claim mobile games
// auth prime-gaming
pg_email: process.env.PG_EMAIL || process.env.EMAIL,
pg_password: process.env.PG_PASSWORD || process.env.PASSWORD,

55
src/epic-games-mobile.js Normal file
View file

@ -0,0 +1,55 @@
// following https://github.com/vogler/free-games-claimer/issues/474
const get = async (platform = 'android') => { // or ios
const r = await fetch(`https://egs-platform-service.store.epicgames.com/api/v2/public/discover/home?count=10&country=DE&locale=en&platform=${platform}&start=0&store=EGS`, {
"method": "GET",
});
const j = await r.json();
// console.log(j);
return j;
}
// $ jq '.data[].topicId' -r
// $ jq '.data[] | {topicId,type} | flatten | @tsv' -r
// mobile-android-carousel featured
// mobile-android-featured-breaker featured
// mobile-android-genre-must-play interactiveIconList
// mobile-android-1pp featured
// mobile-android-fn-exp imageOnly
// android-mega-sale interactiveIconList
// mobile-android-free-game freeGame
// mobile-android-genre-action featured
// mobile-android-genre-free interactiveIconList
// mobile-android-genre-paid interactiveIconList
// $ jq '.data[].offers[].content | {slug: .mapping.slug, price: (.purchase[] | {decimal: .price.decimalPrice, type: .purchaseType})}'
// {
// "slug": "dc-heroes-united-android-de4bc2",
// "price": {
// "decimal": 0,
// "type": "Claim"
// }
// }
// {
// "slug": "ashworld-android-abd8de",
// "price": {
// "decimal": 4.79,
// "type": "Purchase"
// }
// }
const url = s => `https://store.epicgames.com/en-US/p/${s}`;
export const getPlatformGames = async platform => {
const json = await get(platform);
const free_game = json.data.filter(x => x.type == 'freeGame')[0];
// console.log(free_game);
return free_game.offers.map(offer => {
const c = offer.content;
// console.log(c.purchase)
return { title: c.title, url: url(c.mapping.slug) };
});
};
export const getGames = async () => [...await getPlatformGames('android'), ...await getPlatformGames('ios')]
// console.log(await getGames());