Support chinese variant, QQ object in launcher and some code optimizations

This commit is contained in:
2022-02-16 00:49:33 +07:00
parent 048a7ac9d0
commit c22918673b
19 changed files with 389 additions and 58 deletions

33
worthless/installer.py Normal file
View File

@ -0,0 +1,33 @@
import asyncio
import tarfile
import constants
import appdirs
import aiofiles
from pathlib import Path
import shutil
import aiohttp
from worthless.launcher import Launcher
from configparser import ConfigParser
class Installer:
def __init__(self, gamedir: str | Path = Path.cwd(), overseas: bool = True):
if isinstance(gamedir, str):
gamedir = Path(gamedir)
self._gamedir = gamedir
config_file = self._gamedir.joinpath("config.ini")
self._config_file = config_file.resolve()
self._version = None
self._overseas = overseas
self._launcher = Launcher(self._gamedir, self._overseas)
if config_file.exists():
self._version = self._read_version_from_config()
else: # TODO: Use An Anime Game Launcher method (which is more brutal, but it works)
self._version = "mangosus"
def _read_version_from_config(self):
if self._config_file.exists():
raise FileNotFoundError(f"Config file {self._config_file} not found")
cfg = ConfigParser()
cfg.read(str(self._config_file))
return cfg.get("miHoYo", "game_version")