diff --git a/frontend/script.js b/frontend/script.js index 480403f..81c434a 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -1,6 +1,6 @@ document.addEventListener('alpine:init', () => { Alpine.data('app', () => ({ - VERSION: '1.3.2', + VERSION: '1.3.3', // raw data from the backend bannerTypes: {}, diff --git a/wishing-well.nsi b/wishing-well.nsi index 441e43b..3361e91 100644 --- a/wishing-well.nsi +++ b/wishing-well.nsi @@ -2,7 +2,7 @@ !define MUI_ICON "icon.ico" Name "Wishing Well" -OutFile "wishing-well-1.3.2.exe" +OutFile "wishing-well-1.3.3.exe" Unicode True RequestExecutionLevel admin InstallDir "$PROGRAMFILES\Wishing Well" @@ -41,7 +41,7 @@ Section "Wishing Well" File /r "wishing-well.dist\tk*.*" File "wishing-well.dist\libcrypto-1_1.dll" File "wishing-well.dist\libssl-1_1.dll" - File "wishing-well.dist\python39.dll" + File "wishing-well.dist\python310.dll" File "wishing-well.dist\vcruntime140.dll" File "wishing-well.dist\tcl86t.dll" File "wishing-well.dist\tk86t.dll" diff --git a/wishing-well.py b/wishing-well.py index 1456ee6..7adf467 100644 --- a/wishing-well.py +++ b/wishing-well.py @@ -9,7 +9,7 @@ # nuitka-project: --windows-company-name=- # nuitka-project: --windows-product-name=Wishing Well # nuitka-project: --windows-file-description=Wishing Well -# nuitka-project: --windows-product-version=1.3.2 +# nuitka-project: --windows-product-version=1.3.3 import logging import bottle diff --git a/wishing_well/client.py b/wishing_well/client.py index a749691..95c0f08 100644 --- a/wishing_well/client.py +++ b/wishing_well/client.py @@ -152,7 +152,7 @@ def extract_region_and_auth_token(url): def extract_region_and_auth_token_from_file(): path = get_cache_path() if path is None or not path.exists(): - raise LogNotFoundError('Genshin Impact is not installed or has not been started yet.') + raise LogNotFoundError('Genshin Impact is not installed or has not been started yet, or the cache file could not be copied.') with path.open('rb') as fp: cache_file = fp.read() diff --git a/wishing_well/util.py b/wishing_well/util.py index c9c81af..8a93714 100644 --- a/wishing_well/util.py +++ b/wishing_well/util.py @@ -1,5 +1,6 @@ import logging import os +import re import socket import subprocess import sys @@ -29,26 +30,40 @@ def get_data_path(): return path def get_cache_path(): + game_path = None + log_path = Path(os.environ['USERPROFILE']) / 'AppData/LocalLow/miHoYo/Genshin Impact/output_log.txt' + + if not log_path.exists(): + return None + + regex = re.compile('^Warmup file (.+)/GenshinImpact_Data') + with log_path.open('r') as fp: + for line in fp: + match = regex.search(line) + if match is not None: + game_path = match.group(1) + break + + if game_path is None: + return None + + # create a copy of the file so we can also access it while genshin is running. + # python cannot do this without raising an error, and neither can the default + # windows copy command, so we instead delegate this task to powershell's Copy-Item try: - handle = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Genshin Impact', - access=winreg.KEY_WOW64_64KEY | winreg.KEY_READ) - path = winreg.QueryValueEx(handle, 'InstallPath')[0] - handle.Close() - - # create a copy of the file so we can also access it while genshin is running. - # python cannot do this without raising an error, and neither can the default - # windows copy command, so we instead delegate this task to powershell's Copy-Item - try: - path = Path(path) / 'Genshin Impact game/GenshinImpact_Data/webCaches/Cache/Cache_Data/data_2' - copy_path = get_data_path() / 'data_2' - subprocess.check_output(f'powershell.exe -Command "Copy-Item \'{path}\' \'{copy_path}\'"', shell=True) - except (FileNotFoundError, subprocess.CalledProcessError): + path = Path(game_path) / 'GenshinImpact_Data/webCaches/Cache/Cache_Data/data_2' + logging.debug('Cache path is: ' + str(path)) + if not path.exists(): return None - return copy_path - except (OSError, FileNotFoundError): + copy_path = get_data_path() / 'data_2' + subprocess.check_output(f'powershell.exe -Command "Copy-Item \'{path}\' \'{copy_path}\'"', shell=True) + except (FileNotFoundError, subprocess.CalledProcessError) as e: + logging.error('Could not create copy of cache file') return None + return copy_path + def set_up_logging(): log_level = logging.DEBUG if len(sys.argv) > 1 and sys.argv[1] == '--debug' else logging.INFO log_format = '%(asctime)s %(levelname)s: %(message)s'