alexbelgium / hassio-addons

My homeassistant addons
MIT License
1.53k stars 216 forks source link

✨ [REQUEST] free-games-claimer #747

Closed amosyuen closed 1 year ago

amosyuen commented 1 year ago

!!! I have a real life job in parallel to this addon, and don't think I'll be able to add new addons for the moment. You can still however express your interest in case someone would do it

Which addon? https://github.com/vogler/free-games-claimer. Supports epic games, prime gaming and GOG

Is your feature request related to a problem? Please describe. Claim free games from multiple services.

**If a new addon, have you checked on Google that such as addon doesn't already exists?** Yes

Describe the solution you'd like

Configure single add-on to claim all free games.

Describe alternatives you've considered

Not aware of other alternatives

alexbelgium commented 1 year ago

What is strange is that the config.env file is already pushed in the workdir here : https://github.com/alexbelgium/hassio-addons/blob/2d56211be25865a38a489d476eb1c4d8128092d5/free_games_claimer/rootfs/etc/cont-init.d/99-run.sh#L20-L21

Just realized perhaps I should do /data/data/config.env to respect the code you were showing. I'll push a new version to do that

I spent a lot of time trying to solve the VNC not starting thing - but it seems to be getting nowhere.

alexbelgium commented 1 year ago

I also need to re-enable the option to choose which elements to run, I'll push a test10 version

alexbelgium commented 1 year ago

config.env doesn't seem to be working, either in /data/config.env or /data/data/config.env (given that /data is the initial WORKDIR)

KairuByte commented 1 year ago

That's very odd... I think the only time I've ever seen the env variables work was when they needed export in front of them. But looking at the code every way you've set them up looks like they should work.

Maybe if you dropped the later set -a; /./"$CONFIG_HOME"/config.env; set +a? I wonder if that might be causing the code to ignore the set variables somehow? Very much a shot in the dark though.

alexbelgium commented 1 year ago

When they needed export, I didn't use the embedded config.env system but instead read the file line per file and exported them in the bash shell

I can redo it. Set -a was to avoid error messages for undeclared variables

Have you tried adding again the export in front? If it works I can add it dynamically if it is not present, which would allow to respect the config.env format while still exporting it

alexbelgium commented 1 year ago

Current dev status (test11) :

KairuByte commented 1 year ago

I did try adding export previous to the most recent with no luck.

If you wanted to do a real quick test (I will asap) you can try setting the size to 1024 by 768 and seeing if the size message properly reflects that just after the image is spun up.

Edit: test11 worked with export but only the first command in the list. Will test test12 asap.

KairuByte commented 1 year ago

After testing test11 and test12 I can confirm that the environment variables do appear to be properly loading!

That said, test12 seems to still have issues with setting the command arguments. Using node epic-games ; node prime-gaming; node gog I am seeing:

Starting...
/etc/cont-init.d/00-banner.sh: executing
-----------------------------------------------------------
 Add-on: Free Games Claimer (NOT WORKING)
 automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG
-----------------------------------------------------------
 Add-on version: 1.4-test12
 You are running the latest version of this add-on.
 System: Home Assistant OS 10.2  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2023.5.4
 Home Assistant Supervisor: 2023.04.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums
-----------------------------------------------------------
 Provided by: https://github.com/alexbelgium/hassio-addons 
-----------------------------------------------------------
/etc/cont-init.d/01-custom_script.sh: executing
[16:18:25] INFO: Execute /config/addons_autoscripts/free-games-claimer.sh if existing
[16:18:25] INFO: ... no script found
/etc/cont-init.d/20-folders.sh: executing
Creating config location ...
Copying files if needed...
/etc/cont-init.d/99-run.sh: executing
[16:18:26] WARNING: The config.env file found in /config/addons_config/free_games_claimer will be used. Please customize according to https://github.com/vogler/free-games-claimer/tree/main#configuration--options and restart the add-on

[16:18:27] INFO: Starting the app with arguments node epic-games; node prime-gaming; node gog 

Xvfb display server created screen with resolution 1024x768
VNC is running on port 5900 (no password!)
noVNC (VNC via browser) is running on http://localhost:6080
node:internal/modules/cjs/loader:1093
  throw err;
  ^
Error: Cannot find module '/data/epic-games;'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1090:15)
    at Module._load (node:internal/modules/cjs/loader:934:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
Node.js v19.9.0
[16:18:27] INFO: All actions concluded, addon will stop

Side note: The addon doesn't appear to stop after this message is displayed?... I haven't let it sit long, but it appears to run for at least 30 more seconds. I've had to manually stop it every time.

alexbelgium commented 1 year ago

Thanks :) I'll add automatic stop. And check sequential execution. I thought I had the error message only because I didn't have a real account to test

alexbelgium commented 1 year ago

Latest version should work (except for VPN), it will also show in blue exported values from config.env

KairuByte commented 1 year ago

Just... in case, before I run it. Are you censoring anything with the word password in the env variable? You are able to pass usernames and passwords, and keeping a log of those doesn't sound like a good idea.

alexbelgium commented 1 year ago

Well, logs are temporary, they only appear but are not stored anywhere that I am aware of. Anyway it would still be stored locally - which is already the case from the passwords being written as plain text in the config.env. So really the key element is to keep your HA system secure. But I can remove this feature if you prefer

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

KairuByte commented 1 year ago

Apologies for the late follow up. I’ve been able to test and can confirm things run. However. Sequential running may not work?


[23:29:23] INFO: Starting the app with arguments "node epic-games"
Xvfb display server created screen with resolution 1024x768
VNC is running on port 5900 (no password!)
noVNC (VNC via browser) is running on http://localhost:6080
2023-06-15 23:29:25.819 started checking epic-games
Signed in as *********
Free games: [
  'https://store.epicgames.com/en-US/p/guacamelee-2-ac4977',
  'https://store.epicgames.com/en-US/p/guacamelee-stce-7cdbc8'
]
Current free game: Guacamelee! 2
  Already in library! Nothing to claim.
Current free game: Guacamelee! Super Turbo Championship Edition
  Already in library! Nothing to claim.

[23:30:59] INFO: Starting the app with arguments "node prime-gaming"

Xvfb display server created screen with resolution 1024x768
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE) 
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE) 

[23:30:59] INFO: Starting the app with arguments "node gog"

Xvfb display server created screen with resolution 1024x768
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE) 
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE) 
[23:30:59] INFO: All actions concluded, addon will stop in 10 seconds
alexbelgium commented 1 year ago

Hi, indeed sequential running is executed but doesn't connect... Well I'll have to look again

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

KairuByte commented 1 year ago

Bad bot

alexbelgium commented 1 year ago

Well it reminded me of this sorry I was quite caught up in work. I'll have a look again soon

KairuByte commented 1 year ago

Haha no worries, it's not like you're paid to do this, and I'm fairly certain you don't even have a use for this particular add-on.

alexbelgium commented 1 year ago

Hi, I think I got it in version test22. Please let me know!

amosyuen commented 1 year ago

NoVNC still isn't working for me. But looks like it's able to claim epic games for me.

KairuByte commented 1 year ago

Things kinda work now.

Honestly, I think I’m going to revert to using my PC and waking it to handle this… It seems horribly slow on a Pi, and sometimes takes so long things break. I think this may just be an inherent limitation of the Pi and/or image.

hacshacdgacs commented 1 year ago

VNC doesn't work for me either but can confirm that Epic and GOG will claim games without me needing to restart the addon. I'm running this on an old machine and not having any issues with the speed @KairuByte so that may just be a Pi issue.

alexbelgium commented 1 year ago

I think VNC doesn't work due to rpi being too slow... It didn't work on my rpi4 either...

Regarding the script in itself however it seems to run fine on my rpi4 !

Then can we close this? And consider that we'll just don't have noVNC on rpi...

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

alexbelgium commented 1 year ago

Closed with disclaimer that novnc does not work but that the add-on can still work using the config file

amosyuen commented 1 year ago

Hi, would you consider an option to mount a config directory instead of just the config file? Reasons are:

  1. Browser state is saved there. For accounts that need manual 2FA input (such as GOG) a user could run the container manually in terminal and input the 2FA code, then copy the browser data to HA to run automatically.
  2. There are options like RECORD=1 that will record a video to help debug problems in config/record directory, but since directory isn't mounted there isn't an easy way to access the recorded file.
Teberon commented 10 months ago

I am missing something here... I configured the env correctly adding discord, eg, ap, and gog but there's no way to open anything. How do I use this: "Please use config.env to execute the script"?

I get these messages on Discord: prime-gaming failed: page.waitForURL: Timeout 180000ms exceeded.

That is my config.env with reducted information

# NOTIFY='discord://{}/[]' -(Disabled to avoid Discord Spam, but works fine)
EG_EMAIL='[]@[]'
EG_PASSWORD='[]'
EG_OTPKEY='[]'
PG_EMAIL='[]@[]'
PG_PASSWORD='[]'
PG_REDEEM=1
PG_CLAIMDLC=1
PG_OTPKEY='[]'
GOG_EMAIL='[]'
GOG_PASSWORD='[]'
GOG_NEWSLETTER=1

That's the log information until after epic games (others are similar)

Starting...
/etc/cont-init.d/00-banner.sh: executing

-----------------------------------------------------------
 Add-on: Free Games Claimer (NoVNC not working)
 automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG
-----------------------------------------------------------
 Add-on version: 1.5-3
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.2  (amd64 / generic-x86-64)
 Home Assistant Core: 2023.12.4
 Home Assistant Supervisor: 2023.12.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums
-----------------------------------------------------------
 Provided by: https://github.com/alexbelgium/hassio-addons 
-----------------------------------------------------------
/etc/cont-init.d/00-global_var.sh: executing
CMD_ARGUMENTS='node epic-games ; node prime-gaming ; node gog'
CONFIG_LOCATION='/config/addons_config/free_games_claimer/config.env'
Timezone set from Etc/UTC to Europe/Warsaw
/etc/cont-init.d/01-config_yaml.sh: executing
Watch-out: your CONFIG_LOCATION should end by config.yaml, and instead it is config.env
Load environment variables from /config/addons_config/free_games_claimer/config.env if existing
---------------------------------------------------------
Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add‐ons-feature-:-add-env-variables
/config/addons_config/free_games_claimer/config.env
  9:81      warning  line too long (82 > 80 characters)  (line-length)
  16:1      error    syntax error: expected '<document start>', but found '<scalar>' (syntax)

... config file has an invalid yaml format. Please check the file in /config/addons_config/free_games_claimer/config.env. Errors list above.
Error : /etc/cont-init.d/01-config_yaml.sh exiting 1
/etc/cont-init.d/01-custom_script.sh: executing
Execute /config/addons_autoscripts/free-games-claimer.sh if existing
---------------------------------------------------------
... no script found, exiting
Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation
/etc/cont-init.d/20-folders.sh: executing
Creating config location ...
Copying files if needed...
/etc/cont-init.d/99-run.sh: executing
[21:54:42] WARNING: The config.env file found in /config/addons_config/free_games_claimer will be used. Please customize according to https://github.com/vogler/free-games-claimer/tree/main#configuration--options and restart the add-on

[21:54:42] INFO: Getting variables from /config/addons_config/free_games_claimer/config.env

[21:54:42] INFO: Starting the app with arguments "node epic-games"
Version: https://github.com/vogler/free-games-claimer/tree/11db31ea46bf1fd0ec67144f484d3b151ba569b5
Build: Mon, 06 Nov 2023 18:41:08 +0000
Xvfb display server created screen with resolution 1920x1080
VNC is running on port 5900 (no password!)
noVNC (VNC via browser) is running on http://localhost:6080

2023-12-29 21:54:42.885 started checking epic-games
Open http://localhost:6080 to login inside the docker container.
Not signed in anymore. Please login in the browser or here in the terminal.
Login timeout is 180 seconds!
Using email and password from environment.
--- Exception:
page.fill: Timeout 180000ms exceeded.
=========================== logs ===========================
waiting for locator('#password')
============================================================
    at /data/epic-games.js:89:18 {
  name: 'TimeoutError'
}

When I click on Open WebUI I get an endless loading tab opened.

alexbelgium commented 10 months ago

Hi, I don't use the addon so can't help you with the config.env content. However, I can see from your log that the config.env file is correctly loaded by the addon Getting variables from /config/addons_config/free_games_claimer/config.env

So you would have more chance trying on their repo https://github.com/vogler/free-games-claimer. From the log it seems you haven't filled a #password tag in the config.env but they would know better than me what that means.