Skip to content

Commit

Permalink
use different method to find game path; bump version to 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ennea committed Sep 29, 2022
1 parent 6215fae commit 1e9a390
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion frontend/script.js
Original file line number Diff line number Diff line change
@@ -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: {},
Expand Down
4 changes: 2 additions & 2 deletions wishing-well.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion wishing-well.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wishing_well/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
45 changes: 30 additions & 15 deletions wishing_well/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import re
import socket
import subprocess
import sys
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 1e9a390

Please sign in to comment.