From e5ae4b631689ff4f4d13a797ec94f65cd97c5ff1 Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Thu, 29 Sep 2022 16:26:24 +0200 Subject: [PATCH] epic-games: only save screenshot if none exists for game --- epic-games.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/epic-games.js b/epic-games.js index 450e317..e69977e 100644 --- a/epic-games.js +++ b/epic-games.js @@ -1,6 +1,7 @@ import { chromium } from 'playwright'; // stealth plugin needs no outdated playwright-extra import path from 'path'; import { dirs, jsonDb, datetime, stealth, filenamify } from './util.js'; +import { existsSync } from 'fs'; const debug = process.env.PWDEBUG == '1'; // runs non-headless and opens https://playwright.dev/docs/inspector @@ -84,7 +85,8 @@ try { console.log('Current free game:', title); const title_url = page.url().split('/').pop(); const p = path.resolve(dirs.screenshots, 'epic-games', `${title_url}.png`); - await page.screenshot({ path: p, fullPage: false }); // fullPage is quite long... + if (!existsSync(p)) await page.screenshot({ path: p, fullPage: false }); // fullPage is quite long... + continue; if (btnText.toLowerCase() == 'in library') { console.log('Already in library! Nothing to claim.'); } else { // GET