new flag -reldir for the generate_emu_config script to use everything relatively

This commit is contained in:
otavepto 2024-02-24 19:41:14 +02:00 committed by otavepto
parent 883dfac04f
commit 7e240ffec0
3 changed files with 19 additions and 27 deletions

View File

@ -1,3 +1,5 @@
* added a new flag `-reldir` for the `generate_emu_config` script which allows it to generate temp files/folders, and expect input files, relative to the current workig directory, suggested by **[ImportTaste]**
# 2024/2/24
* build the python scripts `achievements_gen.py` and `parse_controller_vdf.py` into binary form using `pyinstaller` for a more user friendly usage, suggested by **[DogancanYr]**

View File

@ -11,6 +11,11 @@ generate_emu_config [options] <app id 1> [app id 2] [app id 3] ...
---
### Available **\[options\]**
To get all available options, run the tool without any arguments.
---
### Login:
You'll be asked each time to enter your username and password.
You can also place a file called `my_login.txt` beside this tool with the following data:
@ -30,28 +35,6 @@ When you login with a non-anonymous account, its ID will be added to the top of
<br/>
## Available **\[options\]**
To get all available options, run the tool without any arguments.
* `app id 1`: the ID of the first app, this is mandatory
* `app id <n>`: multiple/more app IDs to grab the data for
* `-shots`: download some additional screenshots for the app/game
* `-thumbs`: download some additional thumbnails for the app/game
* `-vid`: attempt to download the trailer/promo video
* `-imgs`: download common Steam imgaes, this includes a poster, Steam generated background, icon(s), and some other assets
* `-name`: output the data in a folder with the name of the app/game, illegal characters are removed
* `-cdx`: generate `.ini` file to be used by CODEX emu, this is quite outdated and needs manual editiong
* `-aw`: generate all schemas for Achievement Watcher by xan105: https://github.com/xan105/Achievement-Watcher
* `-clean`: attempt to cleanup/remove the output folder from previous runs, if it exists, before downloading the data again
* `-anon`: use anonymous account to login to Steam instead of using your own,
note that this account has very limited access to data, and it can't download most info
* `-nd`: don't generate `disable_xxx.txt` files
### Example
```bash
generate_emu_config -shots -thumbs -vid -imgs -name -cdx -aw -clean 421050 480
```
---
## Attributions and credits

View File

@ -21,8 +21,11 @@ import queue
import shutil
import traceback
def get_exe_dir():
def get_exe_dir(relative = False):
# https://pyinstaller.org/en/stable/runtime-information.html
if relative:
return os.path.curdir
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
return os.path.dirname(sys.executable)
else:
@ -513,6 +516,7 @@ def help():
print(" -clean: delete any folder/file with the same name as the output before generating any data")
print(" -anon: login as an anonymous account, these have very limited access and cannot get all app details")
print(" -nd: not making predeterminated disable files")
print(" -reldir: generate temp files/folders, and expect input files, relative to the current working directory")
print("\nAll switches are optional except app id, at least 1 app id must be provided\n")
def main():
@ -529,6 +533,7 @@ def main():
GENERATE_ACHIEVEMENT_WATCHER_SCHEMAS = False
CLEANUP_BEFORE_GENERATING = False
ANON_LOGIN = False
RELATIVE_DIR = False
prompt_for_unavailable = True
@ -560,6 +565,8 @@ def main():
ANON_LOGIN = True
elif f'{appid}'.lower() == '-nd':
NODISABLE = True
elif f'{appid}'.lower() == '-reldir':
RELATIVE_DIR = True
else:
print(f'[X] invalid switch: {appid}')
help()
@ -571,12 +578,12 @@ def main():
sys.exit(1)
client = SteamClient()
login_tmp_folder = os.path.join(get_exe_dir(), "login_temp")
login_tmp_folder = os.path.join(get_exe_dir(RELATIVE_DIR), "login_temp")
if not os.path.exists(login_tmp_folder):
os.makedirs(login_tmp_folder)
client.set_credential_location(login_tmp_folder)
my_login_file = os.path.join(get_exe_dir(), "my_login.txt")
my_login_file = os.path.join(get_exe_dir(RELATIVE_DIR), "my_login.txt")
if not ANON_LOGIN and os.path.isfile(my_login_file):
filedata = ['']
with open(my_login_file, "r", encoding="utf-8") as f:
@ -634,7 +641,7 @@ def main():
result = client.login(USERNAME, PASSWORD, None, auth_code, two_factor_code)
# read and prepend top_owners_ids.txt
top_owners_file = os.path.join(get_exe_dir(), "top_owners_ids.txt")
top_owners_file = os.path.join(get_exe_dir(RELATIVE_DIR), "top_owners_ids.txt")
if os.path.isfile(top_owners_file):
filedata = ['']
with open(top_owners_file, "r", encoding="utf-8") as f:
@ -666,7 +673,7 @@ def main():
app_name = f"Unknown_Steam_app_{appid}" # we need this for later use in the Achievement Watcher
print(f"[X] Couldn't find app name on store")
root_backup_dir = os.path.join(get_exe_dir(), "backup")
root_backup_dir = os.path.join(get_exe_dir(RELATIVE_DIR), "backup")
backup_dir = os.path.join(root_backup_dir, f"{appid}")
if not os.path.exists(backup_dir):
os.makedirs(backup_dir)