♻️ refactor(epic-claimer): enhance screenshot path resolution
- improve screenshot path by using path.resolve for better cross-platform compatibility - organize screenshots into a structured directory hierarchy
This commit is contained in:
parent
fd0fc4e981
commit
af90aa7c42
1 changed files with 4 additions and 2 deletions
|
|
@ -15,6 +15,7 @@ import {
|
||||||
} from './src/util.js';
|
} from './src/util.js';
|
||||||
import { cfg } from './src/config.js';
|
import { cfg } from './src/config.js';
|
||||||
|
|
||||||
|
|
||||||
const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games';
|
const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games';
|
||||||
const COOKIES_PATH = path.resolve(cfg.dir.browser, 'epic-cookies.json');
|
const COOKIES_PATH = path.resolve(cfg.dir.browser, 'epic-cookies.json');
|
||||||
const BEARER_TOKEN_NAME = 'EPIC_BEARER_TOKEN';
|
const BEARER_TOKEN_NAME = 'EPIC_BEARER_TOKEN';
|
||||||
|
|
@ -292,8 +293,8 @@ const claimGame = async (page, game) => {
|
||||||
notify_game.status = 'claimed';
|
notify_game.status = 'claimed';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
notify_game.status = 'failed';
|
notify_game.status = 'failed';
|
||||||
const p = screenshot('failed', `${game.offerId || game.pageSlug}_${filenamify(datetime())}.png`);
|
const screenshotPath = path.resolve(cfg.dir.screenshots, 'epic-games', 'failed', `${game.offerId || game.pageSlug}_${filenamify(datetime())}.png`);
|
||||||
await page.screenshot({ path: p, fullPage: true }).catch(() => { });
|
await page.screenshot({ path: screenshotPath, fullPage: true }).catch(() => { });
|
||||||
console.error(' Failed to claim:', e.message);
|
console.error(' Failed to claim:', e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -378,3 +379,4 @@ export const claimEpicGamesNew = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default claimEpicGamesNew;
|
export default claimEpicGamesNew;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue