From 184e96fa2d297d75559bedef17b08e5c401db01d Mon Sep 17 00:00:00 2001 From: tretrauit Date: Wed, 24 Aug 2022 20:14:38 +0700 Subject: [PATCH] patcher: add option to specify predefined patch url This option adds patch_provider to Patcher class, currently you can choose either y0soro or Krock (by default it uses y0soro for latest 3.0.0 patch) --- setup.py | 2 +- worthless/constants.py | 5 ++++- worthless/patcher.py | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 6c334ba..289802c 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ README = (HERE / "README.md").read_text() setup( name='worthless', - version='2.2.0-2', + version='2.2.1', packages=['worthless', 'worthless.classes', 'worthless.classes.launcher', 'worthless.classes.installer'], url='https://git.froggi.es/tretrauit/worthless-launcher', license='MIT License', diff --git a/worthless/constants.py b/worthless/constants.py index 3e01dae..d4517cf 100644 --- a/worthless/constants.py +++ b/worthless/constants.py @@ -7,7 +7,10 @@ APPDIRS=AppDirs(APP_NAME, APP_AUTHOR) LAUNCHER_API_URL_OS = "https://sdk-os-static.hoyoverse.com/hk4e_global/mdk/launcher/api" LAUNCHER_API_URL_CN = "https://sdk-static.mihoyo.com/hk4e_cn/mdk/launcher/api" HDIFFPATCH_GIT_URL="https://github.com/sisong/HDiffPatch" -PATCH_GIT_URL = "https://notabug.org/y0soro/dawn" +PATCH_LIST = { + "Krock": "https://notabug.org/Krock/dawn", + "y0soro": "https://notabug.org/y0soro/dawn" +} TELEMETRY_URL_LIST = [ "log-upload-os.mihoyo.com", "log-upload-eur.mihoyo.com", diff --git a/worthless/patcher.py b/worthless/patcher.py index e534234..eb044f4 100644 --- a/worthless/patcher.py +++ b/worthless/patcher.py @@ -29,10 +29,12 @@ except ImportError: class Patcher: def __init__(self, gamedir: Path | AsyncPath | str = AsyncPath.cwd(), data_dir: str | Path | AsyncPath = None, - patch_url: str = None, overseas=True): + patch_url: str = None, overseas=True, patch_provider="y0soro"): if isinstance(gamedir, str | Path): gamedir = AsyncPath(gamedir) self._gamedir = gamedir + if not patch_url: + patch_url = constants.PATCH_LIST[patch_provider].replace("http://", "https://") self._patch_url = (patch_url if patch_url else constants.PATCH_GIT_URL).replace('http://', 'https://') if not data_dir: self._appdirs = constants.APPDIRS @@ -309,3 +311,4 @@ class Patcher: async def clear_cache(self): await asyncio.to_thread(shutil.rmtree, self._temp_path, ignore_errors=True) + await asyncio.to_thread(shutil.rmtree, self._patch_path, ignore_errors=True)