* Added option to specify multiple urls

- you can specify downloads for games and also dls for owned games etc
This commit is contained in:
4n4n4s 2023-10-03 18:14:53 +00:00
parent a2a83ebd84
commit b4bec61b4f
2 changed files with 36 additions and 34 deletions

View file

@ -89,7 +89,7 @@ Available options/variables and their default values:
| GOG_NEWSLETTER | 0 | Do not unsubscribe from newsletter after claiming a game if 1. | | GOG_NEWSLETTER | 0 | Do not unsubscribe from newsletter after claiming a game if 1. |
| GOG_GIVEAWAY | 1 | Claims giveaway game(s). | | GOG_GIVEAWAY | 1 | Claims giveaway game(s). |
| GOG_FREEGAMES | 0 | Claims other free games that are not demos or prologue games. | | GOG_FREEGAMES | 0 | Claims other free games that are not demos or prologue games. |
| GOG_FREEGAMES_URL | [freegames_url](https://www.gog.com/en/games?priceRange=0,0&languages=en&order=asc:title&hideDLCs=true&excludeTags=demo&excludeTags=freegame) | URL to get games to claim additionally. You can add filters for language or certain categories that you don't like. | | GOG_FREEGAMES_URL | [freegames_url](https://www.gog.com/en/games?priceRange=0,0&languages=en&order=asc:title&hideDLCs=true&excludeTags=demo&excludeTags=freegame) | URLs to additional games to claim. Multiple URLs can be added with ";". You can add filters for language, certain categories, DLCs that you like to include or exclude. |
See `config.js` for all options. See `config.js` for all options.

8
gog.js
View file

@ -239,7 +239,9 @@ async function claimGame(url){
} }
async function claimFreegames(){ async function claimFreegames(){
var freegames_url = cfg.gog_freegames_url; var allLinks = [];
var freegames_urls = cfg.gog_freegames_url.split(";");
for (var freegames_url of freegames_urls) {
if (freegames_url.includes("&hideOwned=true")) { if (freegames_url.includes("&hideOwned=true")) {
freegames_url = freegames_url.replace("&hideOwned=true", ""); freegames_url = freegames_url.replace("&hideOwned=true", "");
} }
@ -247,12 +249,11 @@ async function claimFreegames(){
console.log("Filter for only free games not detected adding it manually."); console.log("Filter for only free games not detected adding it manually.");
freegames_url = freegames_url + "&priceRange=0,0"; freegames_url = freegames_url + "&priceRange=0,0";
} }
console.log("claiming freegames from " + freegames_url); console.log("collecting freegames from " + freegames_url);
await page.goto(freegames_url, { waitUntil: 'networkidle' }); await page.goto(freegames_url, { waitUntil: 'networkidle' });
await page.locator('label[selenium-id="hideOwnedCheckbox"]').click(); // when you add it to url immediately it shows more results await page.locator('label[selenium-id="hideOwnedCheckbox"]').click(); // when you add it to url immediately it shows more results
await page.waitForTimeout(2500); await page.waitForTimeout(2500);
var allLinks = [];
var hasMorePages = true; var hasMorePages = true;
do { do {
const links = await page.locator(".product-tile").all(); const links = await page.locator(".product-tile").all();
@ -275,6 +276,7 @@ async function claimFreegames(){
} }
} while (hasMorePages); } while (hasMorePages);
}
console.log("Found total games: " + allLinks.length); console.log("Found total games: " + allLinks.length);
allLinks = allLinks.filter(function (str) { return !str.endsWith("_prologue"); }); allLinks = allLinks.filter(function (str) { return !str.endsWith("_prologue"); });
allLinks = allLinks.filter(function (str) { return !str.endsWith("_demo"); }); allLinks = allLinks.filter(function (str) { return !str.endsWith("_demo"); });