Module genshin.utility.logfile
Search logfile for authkeys.
Functions
def extract_authkey(string: str) ‑> str | None
-
Expand source code
def extract_authkey(string: str) -> typing.Optional[str]: """Extract an authkey from the provided string.""" match = re.findall(r"https://.+?authkey=([^&#]+)", string, re.MULTILINE) if match: return urllib.parse.unquote(match[-1]) return None
Extract an authkey from the provided string.
def get_authkey(game_location: str | pathlib.Path | None = None,
*,
game: Game | None = None) ‑> str-
Expand source code
def get_authkey(game_location: typing.Optional[PathLike] = None, *, game: typing.Optional[types.Game] = None) -> str: """Get an authkey contained in a datafile.""" authkey = extract_authkey(_read_datafile(game_location, game=game)) if authkey is not None: AUTHKEY_FILE.write_text(authkey) return authkey # otherwise try the tempfile (may be expired!) if AUTHKEY_FILE.is_file(): return AUTHKEY_FILE.read_text() raise ValueError( "No authkey could be found in the logs or in a tempfile. " "Open the history in-game first before attempting to request it." )
Get an authkey contained in a datafile.
-
Expand source code
def get_genshin_banner_ids(logfile: typing.Optional[PathLike] = None) -> typing.Sequence[str]: """Get all banner ids from a log file.""" log = _read_datafile(logfile) ids = re.findall(r"https://.+?gacha_id=([^&#]+)", log, re.MULTILINE) return list(set(ids))
Get all banner ids from a log file.