2022-01-28 13:08:53 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import argparse
|
2022-02-18 04:11:55 +00:00
|
|
|
import asyncio
|
|
|
|
|
2022-02-15 19:55:19 +00:00
|
|
|
import appdirs
|
2022-01-28 13:08:53 +00:00
|
|
|
from pathlib import Path
|
2022-02-16 15:18:56 +00:00
|
|
|
from worthless.launcher import Launcher
|
|
|
|
from worthless.installer import Installer
|
2022-02-16 19:43:21 +00:00
|
|
|
from worthless.patcher import Patcher
|
2022-02-16 15:18:56 +00:00
|
|
|
import worthless.constants as constants
|
2022-01-28 13:08:53 +00:00
|
|
|
|
|
|
|
|
2022-02-15 17:49:33 +00:00
|
|
|
class UI:
|
2022-08-23 10:02:20 +00:00
|
|
|
def __init__(self, gamedir: str, noconfirm: bool, tempdir: str | Path = None, pre_download=False) -> None:
|
2022-07-13 06:52:57 +00:00
|
|
|
self._vo_version = None
|
2022-02-15 17:49:33 +00:00
|
|
|
self._noconfirm = noconfirm
|
|
|
|
self._gamedir = gamedir
|
2022-02-16 15:18:56 +00:00
|
|
|
self._launcher = Launcher(gamedir)
|
2022-02-16 19:43:21 +00:00
|
|
|
self._installer = Installer(gamedir, data_dir=tempdir)
|
2022-02-18 13:09:03 +00:00
|
|
|
self._patcher = Patcher(gamedir, data_dir=tempdir)
|
2022-08-23 10:02:20 +00:00
|
|
|
self._pre_download = pre_download
|
|
|
|
if self._pre_download:
|
|
|
|
print("Pre-download is enabled, use at your own risk!")
|
2022-02-16 19:43:21 +00:00
|
|
|
|
2022-02-18 04:11:55 +00:00
|
|
|
def _ask(self, question):
|
|
|
|
if self._noconfirm:
|
|
|
|
# Fake dialog
|
2022-06-24 18:13:47 +00:00
|
|
|
print(question + " [Y/n]:")
|
2022-02-18 04:11:55 +00:00
|
|
|
return True
|
2022-06-24 19:09:26 +00:00
|
|
|
|
|
|
|
# random text
|
|
|
|
answer = "kurumi3"
|
2022-06-24 18:13:47 +00:00
|
|
|
while answer.lower() not in ['y', 'n', '']:
|
|
|
|
answer = input(question + " [Y/n]: ")
|
|
|
|
return answer.lower() == 'y' or answer == ''
|
2022-01-28 13:08:53 +00:00
|
|
|
|
2022-02-19 11:57:45 +00:00
|
|
|
def override_game_version(self, version: str):
|
|
|
|
self._installer._version = version
|
|
|
|
|
2022-07-13 06:52:57 +00:00
|
|
|
def override_voiceover_version(self, version: str):
|
|
|
|
self._vo_version = version
|
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def get_game_version(self):
|
|
|
|
print(await self._installer.get_game_version())
|
2022-02-16 15:18:56 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def block_telemetry(self):
|
2022-02-26 18:54:20 +00:00
|
|
|
print("Checking for available telemetry to block...")
|
|
|
|
try:
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._patcher.block_telemetry()
|
2022-02-26 18:54:20 +00:00
|
|
|
except ValueError:
|
|
|
|
print("No telemetry to block.")
|
|
|
|
else:
|
|
|
|
print("Telemetry blocked.")
|
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def check_telemetry(self):
|
|
|
|
block_status = await self._patcher.is_telemetry_blocked()
|
2022-02-26 18:54:20 +00:00
|
|
|
if not block_status:
|
|
|
|
print("Telemetry is blocked.")
|
|
|
|
else:
|
|
|
|
print("Telemetry is not blocked, you need to block these hosts below.")
|
2022-06-24 18:13:47 +00:00
|
|
|
for hosts in block_status:
|
|
|
|
print(hosts)
|
2022-02-26 18:54:20 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def _update_from_archive(self, filepath):
|
2022-02-16 19:43:21 +00:00
|
|
|
print("Reverting patches if patched...")
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._patcher.revert_patch(True)
|
|
|
|
print("Updating game from archive (This may takes some time)...")
|
|
|
|
await self._installer.update_game(filepath)
|
2022-03-30 19:09:33 +00:00
|
|
|
self._installer.set_version_config()
|
2022-02-16 19:43:21 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def _install_from_archive(self, filepath, force_reinstall):
|
|
|
|
print("Installing game from archive (This may takes some time)...")
|
|
|
|
print(filepath)
|
|
|
|
await self._installer.install_game(filepath, force_reinstall)
|
2022-03-30 19:09:33 +00:00
|
|
|
self._installer.set_version_config()
|
2022-02-18 01:45:05 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def _apply_voiceover_from_archive(self, filepath):
|
|
|
|
print("Applying voiceover from archive (This may takes some time)...")
|
|
|
|
print("Voiceover archive:", filepath)
|
|
|
|
await self._installer.apply_voiceover(filepath)
|
2022-02-16 19:43:21 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def install_voiceover_from_file(self, filepath):
|
2022-02-17 15:02:08 +00:00
|
|
|
print("Archive voiceover language: {} ({})".format(
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._installer.get_voiceover_archive_language(filepath),
|
|
|
|
"Full archive" if await self._installer.get_voiceover_archive_type(filepath) else "Update archive"))
|
2022-02-16 19:43:21 +00:00
|
|
|
if not self._ask("Do you want to apply this voiceover pack? ({})".format(filepath)):
|
|
|
|
print("Aborting apply process.")
|
|
|
|
return
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._apply_voiceover_from_archive(filepath)
|
2022-02-16 19:43:21 +00:00
|
|
|
print("Voiceover applied successfully.")
|
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def revert_patch(self):
|
2022-02-16 19:43:21 +00:00
|
|
|
print("Reverting patches...")
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._patcher.revert_patch(True)
|
2022-02-16 19:43:21 +00:00
|
|
|
print("Patches reverted.")
|
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def patch_game(self, login_fix: bool = False):
|
2022-02-18 13:09:03 +00:00
|
|
|
print("NOTE: Hereby you are violating the game's Terms of Service!")
|
|
|
|
print("Do not patch the game if you don't know what you are doing!")
|
|
|
|
if not self._ask("Do you want to patch the game? (This will overwrite your game files!)"):
|
|
|
|
print("Aborting patch process.")
|
|
|
|
return
|
2022-06-24 18:13:47 +00:00
|
|
|
await self.block_telemetry()
|
2022-02-26 18:54:20 +00:00
|
|
|
print("Updating patches...")
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._patcher.download_patch()
|
2022-02-26 18:54:20 +00:00
|
|
|
print("Patching game...")
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._patcher.apply_patch(login_fix)
|
2022-02-18 13:09:03 +00:00
|
|
|
print("Game patched.")
|
2022-02-26 18:54:20 +00:00
|
|
|
print("Please refrain from sharing this project to public, thank you.")
|
2022-02-18 13:09:03 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def install_from_file(self, filepath):
|
|
|
|
gamever = await self._installer.get_game_version()
|
|
|
|
print("Archive game version:", await self._installer.get_game_archive_version(filepath))
|
2022-02-16 19:43:21 +00:00
|
|
|
if gamever:
|
2022-06-24 18:13:47 +00:00
|
|
|
print("Current game installation detected. ({})".format(await self._installer.get_game_version()))
|
2022-02-17 15:02:08 +00:00
|
|
|
if not self._ask("Do you want to update the game? ({})".format(filepath)):
|
2022-02-16 19:43:21 +00:00
|
|
|
print("Aborting update process.")
|
|
|
|
return
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._update_from_archive(filepath)
|
2022-02-16 19:43:21 +00:00
|
|
|
print("Game updated successfully.")
|
|
|
|
else:
|
|
|
|
print("No game installation detected.")
|
|
|
|
if not self._ask("Do you want to install the game? ({})".format(filepath)):
|
|
|
|
print("Aborting installation process.")
|
|
|
|
return
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._install_from_archive(filepath, False)
|
2022-02-18 01:45:05 +00:00
|
|
|
print("Game installed successfully.")
|
2022-02-16 19:43:21 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def download_patch(self):
|
2022-02-26 18:54:20 +00:00
|
|
|
print("Downloading patches...")
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._patcher.download_patch()
|
2022-02-26 18:54:20 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def download_game(self):
|
2022-02-19 11:57:45 +00:00
|
|
|
print("Downloading full game (This will take a long time)...")
|
2022-08-23 10:02:20 +00:00
|
|
|
await self._installer.download_full_game(self._pre_download)
|
2022-02-19 11:57:45 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def download_game_update(self):
|
2022-02-19 11:57:45 +00:00
|
|
|
print("Downloading game update (This will take a long time)...")
|
2022-08-23 10:02:20 +00:00
|
|
|
await self._installer.download_game_update(pre_download=self._pre_download)
|
2022-02-19 11:57:45 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def download_voiceover(self, languages: str):
|
|
|
|
res_info = await self._launcher.get_resource_info()
|
2022-02-19 11:57:45 +00:00
|
|
|
for lng in languages.split(" "):
|
|
|
|
for vo in res_info.game.latest.voice_packs:
|
|
|
|
if not self._installer.voiceover_lang_translate(lng) == vo.language:
|
|
|
|
continue
|
|
|
|
print("Downloading voiceover pack for {} (This will take a long time)...".format(lng))
|
2022-08-23 10:02:20 +00:00
|
|
|
await self._installer.download_full_voiceover(lng, pre_download=self._pre_download)
|
2022-02-19 11:57:45 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def download_voiceover_update(self, languages: str):
|
|
|
|
res_info = await self._launcher.get_resource_info()
|
2022-02-19 11:57:45 +00:00
|
|
|
for lng in languages.split(" "):
|
|
|
|
for vo in res_info.game.latest.voice_packs:
|
|
|
|
if not self._installer.voiceover_lang_translate(lng) == vo.language:
|
|
|
|
continue
|
|
|
|
print("Downloading voiceover update pack for {} (This will take a long time)...".format(lng))
|
2022-08-23 10:02:20 +00:00
|
|
|
await self._installer.download_voiceover_update(lng, pre_download=self._pre_download)
|
2022-02-19 11:57:45 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def install_game(self, forced: bool = False):
|
|
|
|
res_info = await self._launcher.get_resource_info()
|
2022-08-23 10:02:20 +00:00
|
|
|
game = res_info.game
|
|
|
|
if self._pre_download:
|
|
|
|
game = res_info.pre_download_game
|
|
|
|
print("Latest game version: {}".format(game.latest.version))
|
2022-02-18 04:11:55 +00:00
|
|
|
if not self._ask("Do you want to install the game?"):
|
|
|
|
print("Aborting game installation process.")
|
|
|
|
return
|
2022-06-24 18:13:47 +00:00
|
|
|
await self.download_game()
|
2022-08-23 10:02:20 +00:00
|
|
|
print("Game archive:", game.latest.get_name())
|
|
|
|
await self._install_from_archive(self._installer.temp_path.joinpath(game.latest.get_name()), forced)
|
2022-02-18 04:11:55 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def install_voiceover(self, languages: str):
|
|
|
|
res_info = await self._launcher.get_resource_info()
|
2022-02-18 04:11:55 +00:00
|
|
|
for lng in languages.split(" "):
|
|
|
|
for vo in res_info.game.latest.voice_packs:
|
|
|
|
if not self._installer.voiceover_lang_translate(lng) == vo.language:
|
|
|
|
continue
|
|
|
|
if not self._ask("Do you want to install this voiceover pack? ({})".format(lng)):
|
|
|
|
print("Aborting voiceover installation process.")
|
2022-08-23 10:02:20 +00:00
|
|
|
break
|
2022-02-18 04:11:55 +00:00
|
|
|
print("Downloading voiceover pack (This will take a long time)...")
|
2022-08-23 10:02:20 +00:00
|
|
|
await self._installer.download_full_voiceover(lng, pre_download=self._pre_download)
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._apply_voiceover_from_archive(
|
|
|
|
self._installer.temp_path.joinpath(vo.get_name())
|
|
|
|
)
|
2022-02-15 17:49:33 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def update_game(self):
|
|
|
|
game_ver = await self._installer.get_game_version()
|
2022-02-18 04:11:55 +00:00
|
|
|
if not game_ver:
|
2022-06-24 18:13:47 +00:00
|
|
|
await self.install_game()
|
2022-02-18 04:11:55 +00:00
|
|
|
return
|
2022-06-24 18:13:47 +00:00
|
|
|
print("Current game installation detected: {}".format(game_ver))
|
|
|
|
diff_archive = await self._installer.get_game_diff_archive()
|
|
|
|
res_info = await self._launcher.get_resource_info()
|
2022-08-23 10:02:20 +00:00
|
|
|
game = res_info.game
|
|
|
|
if self._pre_download:
|
|
|
|
game = res_info.pre_download_game
|
2022-02-18 04:11:55 +00:00
|
|
|
if not diff_archive:
|
|
|
|
print("No game updates available.")
|
|
|
|
return
|
2022-08-23 10:02:20 +00:00
|
|
|
print("Latest game version: {}".format(game.latest.version))
|
2022-02-18 04:11:55 +00:00
|
|
|
if not self._ask("Do you want to update the game?"):
|
|
|
|
print("Aborting game update process.")
|
|
|
|
return
|
|
|
|
print("Downloading game update (This will take a long time)...")
|
2022-08-23 10:02:20 +00:00
|
|
|
await self._installer.download_game_update(pre_download=self._pre_download)
|
2022-02-18 04:11:55 +00:00
|
|
|
print("Installing game update...")
|
2022-07-13 06:52:57 +00:00
|
|
|
await self.install_from_file(self._installer.temp_path.joinpath(diff_archive.get_name()))
|
2022-02-18 04:11:55 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def update_voiceover(self, languages: str | list):
|
|
|
|
if isinstance(languages, str):
|
|
|
|
languages = languages.split(" ")
|
2022-08-16 19:08:28 +00:00
|
|
|
game_ver = self._vo_version or await self._installer.get_game_version()
|
2022-02-18 04:11:55 +00:00
|
|
|
if not game_ver:
|
2022-06-24 18:13:47 +00:00
|
|
|
print("Couldn't detect current game installation, is game installed?")
|
2022-02-18 04:11:55 +00:00
|
|
|
return
|
2022-06-24 18:13:47 +00:00
|
|
|
installed_voiceovers = await self._installer.get_installed_voiceovers()
|
|
|
|
print(f"Installed voiceovers: {None if installed_voiceovers == [] else ', '.join(installed_voiceovers)}")
|
|
|
|
for lng in languages:
|
|
|
|
if self._installer.voiceover_lang_translate(lng, "locale") not in installed_voiceovers:
|
|
|
|
await self.install_voiceover(lng)
|
|
|
|
continue
|
2022-08-23 10:02:20 +00:00
|
|
|
diff_archive = await self._installer.get_voiceover_diff_archive(lng, pre_download=self._pre_download)
|
2022-02-18 04:11:55 +00:00
|
|
|
if not diff_archive:
|
|
|
|
print("No voiceover updates available for {}.".format(lng))
|
|
|
|
continue
|
|
|
|
if not self._ask("Do you want to update this voiceover? ({})".format(lng)):
|
|
|
|
print("Aborting this voiceover language update process.")
|
|
|
|
continue
|
|
|
|
print("Downloading voiceover update (This may takes some time)...")
|
2022-08-23 10:02:20 +00:00
|
|
|
await self._installer.download_voiceover_update(lng, pre_download=self._pre_download)
|
2022-02-18 04:11:55 +00:00
|
|
|
print("Installing voiceover update for {}...".format(lng))
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._apply_voiceover_from_archive(self._installer.temp_path.joinpath(diff_archive.get_name()))
|
|
|
|
|
|
|
|
async def update_game_voiceover(self, languages: str):
|
|
|
|
await self.update_game()
|
|
|
|
await self.update_voiceover(languages)
|
|
|
|
|
2022-07-13 06:52:57 +00:00
|
|
|
async def update_voiceover_all(self):
|
|
|
|
await self.update_voiceover(await self._installer.get_installed_voiceovers())
|
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def update_all(self):
|
|
|
|
await self.update_game()
|
|
|
|
await self.update_voiceover(await self._installer.get_installed_voiceovers())
|
2022-02-18 04:11:55 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def verify_game(self):
|
|
|
|
game_ver = await self._installer.get_game_version()
|
|
|
|
if not game_ver:
|
|
|
|
print("Couldn't detect current game installation, is game installed?")
|
|
|
|
return
|
|
|
|
print("Verifying game contents... (This may takes a long time)")
|
|
|
|
failed_files = await self._installer.verify_game(ignore_mismatch=True)
|
|
|
|
if not failed_files:
|
|
|
|
print("All good.")
|
|
|
|
return
|
|
|
|
print("Some game files got corrupted (mismatch md5), uh oh.")
|
|
|
|
for file in failed_files:
|
|
|
|
print("{}: expected {}, actual {}".format(file[0], file[1], file[2]))
|
2022-02-15 17:49:33 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def clear_cache(self):
|
2022-06-24 19:09:26 +00:00
|
|
|
if self._ask("Do you want to clear Installer cache (contains downloaded game files, etc)?"):
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._installer.clear_cache()
|
2022-06-24 19:09:26 +00:00
|
|
|
if self._ask("Do you want to clear Patcher cache (contains files used to patch)?"):
|
2022-06-24 18:13:47 +00:00
|
|
|
await self._patcher.clear_cache()
|
2022-01-28 13:08:53 +00:00
|
|
|
|
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
async def main():
|
2022-02-15 19:55:19 +00:00
|
|
|
default_dirs = appdirs.AppDirs(constants.APP_NAME, constants.APP_AUTHOR)
|
2022-02-15 17:49:33 +00:00
|
|
|
parser = argparse.ArgumentParser(prog="worthless", description="A worthless launcher written in Python.")
|
2022-02-15 19:55:19 +00:00
|
|
|
parser.add_argument("-D", "--dir", action="store", type=Path, default=Path.cwd(),
|
2022-01-28 13:08:53 +00:00
|
|
|
help="Specify the game directory (default current working directory)")
|
2022-02-15 19:55:19 +00:00
|
|
|
parser.add_argument("-W", "--temporary-dir", action="store", type=Path, default=None,
|
|
|
|
help="Specify the temporary directory (default {} and {})".format(default_dirs.user_data_dir,
|
2022-02-16 19:43:21 +00:00
|
|
|
default_dirs.user_cache_dir))
|
2022-02-15 17:49:33 +00:00
|
|
|
parser.add_argument("-S", "--install", action="store_true",
|
2022-02-16 15:18:56 +00:00
|
|
|
help="Install/update the game (if not already installed, else do nothing)")
|
2022-02-16 19:43:21 +00:00
|
|
|
parser.add_argument("-U", "--install-from-file", action="store", type=Path, default=None,
|
|
|
|
help="Install the game from an archive (if not already installed, \
|
|
|
|
else update from archive)")
|
|
|
|
parser.add_argument("-Uv", "--install-voiceover-from-file", action="store", type=Path, default=None,
|
|
|
|
help="Install the voiceover from an archive (if not already installed, \
|
2022-02-15 17:49:33 +00:00
|
|
|
else update from archive)")
|
|
|
|
parser.add_argument("-Sp", "--patch", action="store_true",
|
|
|
|
help="Patch the game (if not already patched, else do nothing)")
|
2022-02-18 13:09:03 +00:00
|
|
|
parser.add_argument("--login-fix", action="store_true",
|
|
|
|
help="Patch the game to fix login issues (if not already patched, else do nothing)")
|
2022-02-19 11:57:45 +00:00
|
|
|
parser.add_argument("-Sy", "--update", action="store", type=str, default="",
|
2022-02-15 17:49:33 +00:00
|
|
|
help="Update the game and specified voiceover pack only (or install if not found)")
|
2022-02-19 11:57:45 +00:00
|
|
|
parser.add_argument("-Sw", "--download-game", action="store_true",
|
|
|
|
help="Download the full game to the temporary directory")
|
2022-06-26 21:09:47 +00:00
|
|
|
parser.add_argument("-Swp", "--download-patch", action="store_true",
|
|
|
|
help="Download/Update the game patch to the temporary directory")
|
2022-02-19 11:57:45 +00:00
|
|
|
parser.add_argument("-Swv", "--download-voiceover", action="store", type=str,
|
|
|
|
help="Download the full voiceover to the temporary directory")
|
|
|
|
parser.add_argument("-Syw", "--download-game-update", action="store", type=str, default="",
|
|
|
|
help="Download the game and the voiceover update to the temporary directory")
|
|
|
|
parser.add_argument("-Sywv", "--download-voiceover-update", action="store", type=str,
|
|
|
|
help="Download the voiceover update to the temporary directory")
|
2022-02-18 04:11:55 +00:00
|
|
|
parser.add_argument("-Sv", "--update-voiceover", action="store", type=str,
|
2022-02-16 15:18:56 +00:00
|
|
|
help="Update the voiceover pack only (or install if not found)")
|
2022-02-15 19:55:19 +00:00
|
|
|
parser.add_argument("-Syu", "--update-all", action="store_true",
|
2022-02-15 17:49:33 +00:00
|
|
|
help="Update the game and all installed voiceover packs (or install if not found)")
|
2022-08-23 10:02:20 +00:00
|
|
|
parser.add_argument("-Scc", "--clear-cache", action="store_true", help="Clear cache used by worthless")
|
2022-02-15 17:49:33 +00:00
|
|
|
parser.add_argument("-Rs", "--remove", action="store_true", help="Remove the game (if installed)")
|
|
|
|
parser.add_argument("-Rp", "--remove-patch", action="store_true", help="Revert the game patch (if patched)")
|
|
|
|
parser.add_argument("-Rv", "--remove-voiceover", action="store_true", help="Remove a Voiceover pack (if installed)")
|
2022-06-24 18:13:47 +00:00
|
|
|
parser.add_argument("-V", "--verify", action="store_true", help="Verify the game installation")
|
2022-08-23 10:02:20 +00:00
|
|
|
parser.add_argument("--predownload", action="store_true", help="Download the game for the next update", default=False)
|
2022-02-16 15:18:56 +00:00
|
|
|
parser.add_argument("--get-game-version", action="store_true", help="Get the current game version")
|
|
|
|
parser.add_argument("--no-overseas", action="store_true", help="Don't use overseas server")
|
2022-02-26 18:54:20 +00:00
|
|
|
parser.add_argument("--check-telemetry", action="store_true", help="Check for the telemetry information")
|
2022-02-19 11:57:45 +00:00
|
|
|
parser.add_argument("--from-ver", action="store", help="Override the detected game version", type=str, default=None)
|
2022-07-13 06:52:57 +00:00
|
|
|
parser.add_argument("--from-vo-ver", action="store", help="Override the detected game version for voiceover "
|
|
|
|
"detection", type=str, default=None)
|
2022-01-28 13:08:53 +00:00
|
|
|
parser.add_argument("--noconfirm", action="store_true",
|
2022-02-15 17:49:33 +00:00
|
|
|
help="Do not ask any for confirmation. (Ignored in interactive mode)")
|
2022-01-28 13:08:53 +00:00
|
|
|
args = parser.parse_args()
|
2022-02-16 19:43:21 +00:00
|
|
|
if args.temporary_dir:
|
|
|
|
args.temporary_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
2022-08-23 10:02:20 +00:00
|
|
|
ui = UI(args.dir, args.noconfirm, args.temporary_dir, args.predownload)
|
2022-02-15 17:49:33 +00:00
|
|
|
|
2022-01-28 13:08:53 +00:00
|
|
|
if args.install and args.update:
|
|
|
|
raise ValueError("Cannot specify both --install and --update arguments.")
|
|
|
|
|
2022-02-16 19:43:21 +00:00
|
|
|
if args.install_from_file and args.update:
|
|
|
|
raise ValueError("Cannot specify both --install-from-file and --update arguments.")
|
|
|
|
|
|
|
|
if args.install_voiceover_from_file and args.update:
|
|
|
|
raise ValueError("Cannot specify both --install-voiceover-from-file and --update arguments.")
|
|
|
|
|
|
|
|
if args.install_from_file and args.install:
|
|
|
|
raise ValueError("Cannot specify both --install-from-file and --install arguments.")
|
|
|
|
|
2022-02-26 18:54:20 +00:00
|
|
|
if args.from_ver:
|
|
|
|
ui.override_game_version(args.from_ver)
|
|
|
|
|
2022-09-28 05:51:27 +00:00
|
|
|
if args.from_vo_ver:
|
|
|
|
ui.override_voiceover_version(args.from_ver)
|
|
|
|
|
2022-02-16 15:18:56 +00:00
|
|
|
if args.get_game_version:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.get_game_version()
|
2022-02-16 15:18:56 +00:00
|
|
|
|
2022-02-26 18:54:20 +00:00
|
|
|
if args.check_telemetry:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.check_telemetry()
|
|
|
|
|
2022-06-24 19:09:26 +00:00
|
|
|
if args.clear_cache:
|
|
|
|
await ui.clear_cache()
|
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
# Download
|
2022-02-26 18:54:20 +00:00
|
|
|
|
2022-02-19 11:57:45 +00:00
|
|
|
if args.download_game:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.download_game()
|
2022-02-19 11:57:45 +00:00
|
|
|
|
2022-06-26 21:09:47 +00:00
|
|
|
if args.download_patch:
|
|
|
|
await ui.download_patch()
|
|
|
|
|
2022-02-19 11:57:45 +00:00
|
|
|
if args.download_voiceover:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.download_voiceover(args.download_voiceover)
|
2022-02-19 11:57:45 +00:00
|
|
|
|
|
|
|
if args.download_game_update:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.download_game_update()
|
2022-02-19 11:57:45 +00:00
|
|
|
|
|
|
|
if args.download_voiceover_update:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.download_voiceover_update(args.download_voiceover_update)
|
|
|
|
|
|
|
|
# Install
|
2022-02-19 11:57:45 +00:00
|
|
|
|
2022-01-28 13:08:53 +00:00
|
|
|
if args.install:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.install_game()
|
|
|
|
|
|
|
|
if args.install_from_file:
|
|
|
|
await ui.install_from_file(args.install_from_file)
|
|
|
|
|
|
|
|
if args.install_voiceover_from_file:
|
|
|
|
await ui.install_voiceover_from_file(args.install_voiceover_from_file)
|
|
|
|
|
|
|
|
# Update
|
2022-01-28 13:08:53 +00:00
|
|
|
|
2022-03-30 19:09:33 +00:00
|
|
|
if args.update_all:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.update_all()
|
2022-03-30 19:09:33 +00:00
|
|
|
|
2022-01-28 13:08:53 +00:00
|
|
|
if args.update:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.update_game_voiceover(args.update)
|
2022-02-18 04:11:55 +00:00
|
|
|
|
|
|
|
if args.update_voiceover:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.update_voiceover(args.update_voiceover)
|
2022-02-16 19:43:21 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
# Patch
|
2022-02-16 19:43:21 +00:00
|
|
|
|
2022-02-18 13:09:03 +00:00
|
|
|
if args.patch:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.patch_game(args.login_fix)
|
2022-02-18 13:09:03 +00:00
|
|
|
|
2022-02-16 19:43:21 +00:00
|
|
|
if args.remove_patch:
|
2022-06-24 18:13:47 +00:00
|
|
|
await ui.revert_patch()
|
|
|
|
|
|
|
|
# Verify
|
2022-01-28 13:08:53 +00:00
|
|
|
|
2022-06-24 18:13:47 +00:00
|
|
|
if args.verify:
|
|
|
|
await ui.verify_game()
|
2022-01-28 13:08:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2022-06-24 18:13:47 +00:00
|
|
|
asyncio.run(main())
|