34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
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")
|