Skip to content

Commit

Permalink
V1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Revadike committed Feb 10, 2020
1 parent 17299cd commit 6bacc43
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 35 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ Claim [available free game promotions](https://www.epicgames.com/store/free-game

## Instructions
1. Download/clone repo
2. Edit `index.js` to include your EpicGames credentials
2. Run `npm install`
3. Run `node index.js`
2. (Optional) Edit `config.json` to include your EpicGames credentials
3. Run `npm install`
4. Run `node gimme_free_epic_shit` or `node gimme_free_epic_shit USERNAME PASSWORD`

## Changelog
V1.1.0
* Added support for email/password arguments
* Moved saved credentials to config.json
* Ensured all search results are returned
* Fixed program not exiting

V1.0.0
* Initial release
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"email": "YOUR_EMAIL_HERE",
"password": "YOUR_PASSWORD_HERE"
}
53 changes: 53 additions & 0 deletions gimme_free_epic_shit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const { Launcher } = require(`epicgames-client`);
const { email, password } = require(`${__dirname}/config.json`);
const epic = new Launcher({
email: process.argv[2] || email,
password: process.argv[3] || password
});

(async () => {
if (!await epic.init() || !await epic.login()) {
throw new Error(`Error while initialize or login process.`);
}

console.log(`Logged in as ${epic.account.name} (${epic.account.id})`);

let getAllOffers = async (ns, n=100) => {
let i = 0;
let results = [];
while ((i * n) - results.length === 0) {
let { elements } = await epic.getOffersForNamespace(ns, n, n * i++);
results = results.concat(elements);
}
return results;
};

let all = await getAllOffers(`epic`);
let freegames = all.filter(game => game.categories.find(cat => cat.path === `freegames`));

for (let game of freegames) {
let namespace = game.customAttributes[`com.epicgames.app.offerNs`].value
if (!namespace) {
continue;
}

let offers = await getAllOffers(namespace);
let offer = offers.find(game => game.currentPrice === 0 && game.discountPercentage === 0);
if (!offer) {
continue;
}

let purchased = await epic.purchase(offer, 1);
if (purchased) {
console.log(`Successfully claimed ${offer.title} (${purchased})`);
}
}

await epic.logout();
console.log(`Enjoy!`);
process.exit(0);

})().catch(err => {
console.error(err);
process.exit(1)
});
30 changes: 0 additions & 30 deletions index.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "epicgames-freebies-claimer",
"description": "Claim free game promotions from the Epic Game Store",
"version": "1.0.0",
"version": "1.1.0",
"author": "Revadike",
"homepage": "https://revadike.com",
"url": "https://github.com/revadike/epicgames-freebies-claimer",
Expand All @@ -10,4 +10,4 @@
"dependencies": {
"epicgames-client": "latest"
}
}
}

0 comments on commit 6bacc43

Please sign in to comment.