* Added option to specify multiple urls
- you can specify downloads for games and also dls for owned games etc
This commit is contained in:
parent
a2a83ebd84
commit
b4bec61b4f
2 changed files with 36 additions and 34 deletions
|
|
@ -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.
|
||||||
|
|
|
||||||
66
gog.js
66
gog.js
|
|
@ -239,42 +239,44 @@ async function claimGame(url){
|
||||||
}
|
}
|
||||||
|
|
||||||
async function claimFreegames(){
|
async function claimFreegames(){
|
||||||
var freegames_url = cfg.gog_freegames_url;
|
|
||||||
if (freegames_url.includes("&hideOwned=true")) {
|
|
||||||
freegames_url = freegames_url.replace("&hideOwned=true", "");
|
|
||||||
}
|
|
||||||
if (!freegames_url.includes("priceRange=0,0")) {
|
|
||||||
console.log("Filter for only free games not detected adding it manually.");
|
|
||||||
freegames_url = freegames_url + "&priceRange=0,0";
|
|
||||||
}
|
|
||||||
console.log("claiming freegames from " + freegames_url);
|
|
||||||
|
|
||||||
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.waitForTimeout(2500);
|
|
||||||
var allLinks = [];
|
var allLinks = [];
|
||||||
var hasMorePages = true;
|
var freegames_urls = cfg.gog_freegames_url.split(";");
|
||||||
do {
|
for (var freegames_url of freegames_urls) {
|
||||||
const links = await page.locator(".product-tile").all();
|
if (freegames_url.includes("&hideOwned=true")) {
|
||||||
const gameUrls = await Promise.all(
|
freegames_url = freegames_url.replace("&hideOwned=true", "");
|
||||||
links.map(async (game) => {
|
|
||||||
var urlSlug = await game.getAttribute("href");
|
|
||||||
return urlSlug;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
for (const url of gameUrls) {
|
|
||||||
allLinks.push(url);
|
|
||||||
}
|
}
|
||||||
if (await page.locator('.small-pagination__item--next.disabled').isVisible()){
|
if (!freegames_url.includes("priceRange=0,0")) {
|
||||||
hasMorePages = false;
|
console.log("Filter for only free games not detected adding it manually.");
|
||||||
console.log("last page");
|
freegames_url = freegames_url + "&priceRange=0,0";
|
||||||
} else {
|
|
||||||
await page.locator(".small-pagination__item--next").first().click();
|
|
||||||
console.log("next page - waiting");
|
|
||||||
await page.waitForTimeout(5000); // wait until page is loaded it takes some time with filters
|
|
||||||
}
|
}
|
||||||
|
console.log("collecting freegames from " + freegames_url);
|
||||||
|
|
||||||
} while (hasMorePages);
|
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.waitForTimeout(2500);
|
||||||
|
var hasMorePages = true;
|
||||||
|
do {
|
||||||
|
const links = await page.locator(".product-tile").all();
|
||||||
|
const gameUrls = await Promise.all(
|
||||||
|
links.map(async (game) => {
|
||||||
|
var urlSlug = await game.getAttribute("href");
|
||||||
|
return urlSlug;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
for (const url of gameUrls) {
|
||||||
|
allLinks.push(url);
|
||||||
|
}
|
||||||
|
if (await page.locator('.small-pagination__item--next.disabled').isVisible()){
|
||||||
|
hasMorePages = false;
|
||||||
|
console.log("last page");
|
||||||
|
} else {
|
||||||
|
await page.locator(".small-pagination__item--next").first().click();
|
||||||
|
console.log("next page - waiting");
|
||||||
|
await page.waitForTimeout(5000); // wait until page is loaded it takes some time with filters
|
||||||
|
}
|
||||||
|
|
||||||
|
} 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"); });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue