vogler / free-games-claimer

Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG.
GNU Affero General Public License v3.0
2.21k stars 139 forks source link

Release npm package #219

Open vogler opened 9 months ago

vogler commented 9 months ago

To have a lightweight alternative to the Docker image (currently shows captcha), it would be good to be able to do npx free-games-claimer.

People than just have to install Node.js/npm instead of Docker. Notifications would still require pip install apprise. Maybe there's some similar npm package one could use.

ladiko commented 8 months ago

On Windows I just installed git and nodejs, cloned the repository and added a cmd-script which will handle everything else automatically like downloading and/or updating the browser, updating the repository and so on;

cd /d "%~dp0"

REM uncomment next line if you want to use browser window login
REM set SHOW=1

@REM if script is called with "log" as argument / parameter,
@REM restart with logging to file f.e. for Windows Task Scheduler
if "%~1" == "log" (
    "%~f0" nil > "%~dp0\free-games-claimer.log" 2>&1
    exit
)

git reset -q --hard
git pull -q

@REM by default all browsers (chromium, firefox, webkit) are downloaded
@REM disable browser download during npm update/install
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
cmd /c npm update --silent

@REM by default browsers are downloaded to %LOCALAPPDATA%\pw-browsers
@REM set browser download location to a path inside the free-games-claimer directory
set PLAYWRIGHT_BROWSERS_PATH=%~dp0\pw-browsers
cmd /c npx --quiet playwright install firefox

node epic-games
node unrealengine
node gog
node prime-gaming

@REM cleanup firefox cache
rmdir /s /q "%LOCALAPPDATA%\ms-playwright" "%~dp0\data\screenshots\" "%~dp0\data\browser\cache2" "%~dp0\data\browser\startupCache" "%~dp0\data\browser\storage"
del /f "%~dp0\data\browser\favicons.sqlite" "%~dp0\data\browser\places.sqlite"

if "%~1" == "" pause

So if its's double clicked, the repository gets updated and you see the progress inside a command line window, if called by task scheduler with logas argument, the output gets logged to the file free-games-claimer.log to check later if calling it by task scheduler works, The folder has a size of 241 MB mostly cause of firefox (plus nodejs and git).

vogler commented 8 months ago

Any reason you delete the cache? Just to save space or did it help with something?

ladiko commented 7 months ago

No real reason to delete the cache, The reason to use the cmd version instead of the docker image is to save space. I would even prefer to use the globally installed firefox or the much smaller webkit browser instead of 200megs for an extra firefox, but yeah that's just my paranoid way of using as less space as possible.

As your initial issue topic is about an npm package, it means it would have to be JavaScript? I think the cmd-file is quite okay for Windows users to adapt and if someon adds an equivalent sh-file for Linux it would be a quite minimalistic solutions for interested users?

vogler commented 7 months ago

You can use your global Firefox by setting executablePath in launchPersistentContext. Probably not worth the trouble though (may break on version change, safety...). https://playwright.dev/docs/browsers#managing-browser-binaries - doesn't look like webkit is much smaller (maybe the docs are outdated though):

$ du -hs ~/Library/Caches/ms-playwright/*
281M  chromium-XXXXXX
187M  firefox-XXXX
180M  webkit-XXXX