pg: dlc: try/catch for each dlc, #55

This commit is contained in:
Ralf Vogler 2023-05-18 17:32:02 +02:00
parent 0d074d0397
commit 7fb872608d

View file

@ -264,6 +264,7 @@ try {
await games.screenshot({ path: p }); // screenshot of all claimed games await games.screenshot({ path: p }); // screenshot of all claimed games
} }
// https://github.com/vogler/free-games-claimer/issues/55
if (cfg.pg_claimdlc) { if (cfg.pg_claimdlc) {
console.log('Trying to claim in-game content...'); console.log('Trying to claim in-game content...');
await page.click('button[data-type="InGameLoot"]'); await page.click('button[data-type="InGameLoot"]');
@ -303,6 +304,7 @@ try {
db.data[user][title] ||= { title, time: datetime(), store: 'DLC', status: 'failed: need account linking' }; db.data[user][title] ||= { title, time: datetime(), store: 'DLC', status: 'failed: need account linking' };
const notify_game = { title, url }; const notify_game = { title, url };
notify_games.push(notify_game); // status is updated below notify_games.push(notify_game); // status is updated below
try {
await page.goto(url, { waitUntil: 'domcontentloaded' }); await page.goto(url, { waitUntil: 'domcontentloaded' });
// most games have a button 'Get in-game content' // most games have a button 'Get in-game content'
// epic-games: Fall Guys: Claim now -> Continue -> Go to Epic Games (despite account linked and logged into epic-games) -> not tied to account but via some cookie? // epic-games: Fall Guys: Claim now -> Continue -> Go to Epic Games (despite account linked and logged into epic-games) -> not tied to account but via some cookie?
@ -322,10 +324,14 @@ try {
// notify_game.status = `<a href="${redeem[store]}">${redeem_action}</a> ${code} on ${store}`; // notify_game.status = `<a href="${redeem[store]}">${redeem_action}</a> ${code} on ${store}`;
} }
// await page.pause(); // await page.pause();
} catch (error) {
console.error(error);
} finally {
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' });
await page.click('button[data-type="InGameLoot"]'); await page.click('button[data-type="InGameLoot"]');
} }
} }
}
} catch (error) { } catch (error) {
console.error(error); // .toString()? console.error(error); // .toString()?
process.exitCode ||= 1; process.exitCode ||= 1;