claabs / epicgames-freegames-node

Automatically login and find available free games the Epic Games Store. Sends you a prepopulated checkout link so you can complete the checkout after logging in. Supports multiple accounts, login sessions, and scheduled runs.
https://hub.docker.com/r/charlocharlie/epicgames-freegames
MIT License
1.39k stars 92 forks source link

Suggestion - add other free games to script #22

Closed Andrej730 closed 9 months ago

Andrej730 commented 4 years ago

It seems that EGS sometimes has some other free games to offer. This week it is https://www.epicgames.com/store/en-US/product/sludge-life/home (it is shown at the https://www.epicgames.com/store/en-US/free-games ) My suggestion is to include them in script.

bagage commented 4 years ago

Same for https://www.epicgames.com/store/fr/product/a-total-war-saga-troy/home which is 24h free.

claabs commented 4 years ago

I did some digging on this a while back, and I found a GraphQL query that can list all games from the backend with their promotional offers. The issue is that there's 2000 games, which is about 1MB of data. I have very little experience with GraphQL, but I'd like to find a way to filter by discount amount so we don't have a huge request that we have to filter through.

If anyone wants to mess around with it, here's the query:

curl --location --request POST 'https://www.epicgames.com/store/backend/graphql-proxy' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query searchStoreQuery($allowCountries: String, $category: String, $count: Int, $country: String!, $keywords: String, $locale: String, $namespace: String, $sortBy: String, $sortDir: String, $start: Int, $tag: String) {\r\n  Catalog {\r\n    searchStore(allowCountries: $allowCountries, category: $category, count: $count, country: $country, keywords: $keywords, locale: $locale, namespace: $namespace, sortBy: $sortBy, sortDir: $sortDir, start: $start, tag: $tag\r\n    ) {\r\n      elements {\r\n        title\r\n        id\r\n        namespace\r\n        description\r\n        productSlug\r\n        items {\r\n          id\r\n          namespace\r\n        }\r\n        promotions(category: $category) {\r\n          promotionalOffers {\r\n            promotionalOffers {\r\n              startDate\r\n              endDate\r\n              discountSetting {\r\n                discountType\r\n                discountPercentage\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n      paging {\r\n        count\r\n        total\r\n      }\r\n    }\r\n  }\r\n}","variables":{"category":"games","sortBy":"effectiveDate","sortDir":"asc","count":1000,"country":"US","allowCountries":"US","locale":"en-US","start":0}}'
Andrej730 commented 4 years ago

It's seems script doesn't see 2 out of 5 currently available free games:

claabs commented 4 years ago

My thought was that the script should redeem the games that are temporarily free. Thimbleweed and 3/10 Ep 3 appear to be free forever. I'm worried that if it redeems all free games, it could get out of hand (e.g. the thousands of free games on Steam).

I can add a variable to redeem all free games no matter what.

Andrej730 commented 4 years ago

It would be nice option to have. I had the script that was redeeming all free games on steam and it was a mess because it was redeeming all kind of useless stuff - like game trailers, demo-versions etc. Hopefully on EGS there is a way to filter out only actual games and activating all free games would not be that messy.

Banner-Keith commented 2 years ago

@claabs This game is not being purchased. It doesn't appear to always be free so I'm not sure what the deal is. I'd be happy to try to help figure it out if you want.

https://www.epicgames.com/store/en-US/p/godfall--challenger-edition

claabs commented 2 years ago

@claabs This game is not being purchased. It doesn't appear to always be free so I'm not sure what the deal is. I'd be happy to try to help figure it out if you want.

https://www.epicgames.com/store/en-US/p/godfall--challenger-edition

This was due to captchas being added recently. It was already fixed in #192. Pull the latest image for the fix.

Banner-Keith commented 2 years ago

I'll give that a shot thank you.

Banner-Keith commented 2 years ago

It did end up purchasing Prison Architect properly by sending me the captcha, but this game isn't showing up at all.

I have hcaptcha commented out right now since that is not working.

[2021-12-15 12:47:40.126 -0700] INFO (43 on epicgames-freegames): Available free games
user: "myemail@example.com"
availableGames: [
"Prison Architect"
]
[2021-12-15 12:47:40.574 -0700] INFO (43 on epicgames-freegames): Unpurchased free games
user: "myemail@example.com"
purchasableGames: [
"Prison Architect"
]
[2021-12-15 12:47:40.574 -0700] INFO (43 on epicgames-freegames): Purchasing Prison Architect
[2021-12-15 12:47:42.913 -0700] WARN (HTTPError/43 on epicgames-freegames): Response code 400 (Bad Request)
HTTPError: Response code 400 (Bad Request)
at Request.<anonymous> (/usr/app/node_modules/got/dist/source/as-promise/index.js:117:42)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
[2021-12-15 12:47:42.913 -0700] WARN (43 on epicgames-freegames): API purchase experienced an error, trying puppeteer purchase

[2021-12-15 12:47:42.914 -0700] WARN (43 on epicgames-freegames): hcaptchaAccessibilityUrl not configured, captchas are less likely to be bypassed. Follow this guide to set it up: https://github.com/claabs/epicgames-freegames-node#hcaptcha-accessibility-cookies
[2021-12-15 12:47:52.229 -0700] INFO (43 on epicgames-freegames): Go to this URL and do something
user: "myemail@example.com"
url: "http://epicgames-freegames.myinternalnetwork.internal:3000/?targetId=16CC67453F21673C1893209AE86BE403"
[2021-12-15 12:48:21.484 -0700] INFO (43 on epicgames-freegames): Done purchasing Prison Architect

I restarted it to force it to run

[2021-12-15 13:02:19.760 -0700] INFO (43 on epicgames-freegames): Checking free games for myemail@example.com
[2021-12-15 13:02:27.507 -0700] INFO (43 on epicgames-freegames): Successfully refreshed login
user: "myemail@example.com"
[2021-12-15 13:02:28.154 -0700] INFO (43 on epicgames-freegames): Available free games
user: "myemail@example.com"
availableGames: [
"Prison Architect"
]
[2021-12-15 13:02:28.626 -0700] INFO (43 on epicgames-freegames): Unpurchased free games
user: "myemail@example.com"
purchasableGames: []
claabs commented 9 months ago

This was implemented a while back. Closing now.