fix: simplified chinese returning inconsistent results

This commit is contained in:
seria_ati 2023-06-16 11:22:45 +08:00
parent bfd5e08aab
commit c1f5b80b56
No known key found for this signature in database
GPG Key ID: 09F80B1D01CE9315

View File

@ -11,7 +11,7 @@ from .models.v1 import StarrailInfoParsedV1
class Language(Enum): class Language(Enum):
CHT = "cht" CHT = "cht"
CHS = "chs" CHS = "cn"
DE = "de" DE = "de"
EN = "en" EN = "en"
ES = "es" ES = "es"
@ -40,7 +40,9 @@ class MihomoAPI:
""" """
BASE_URL: typing.Final[str] = "https://api.mihomo.me/sr_info_parsed" BASE_URL: typing.Final[str] = "https://api.mihomo.me/sr_info_parsed"
ASSET_URL: typing.Final[str] = "https://raw.githubusercontent.com/Mar-7th/StarRailRes/master" ASSET_URL: typing.Final[
str
] = "https://raw.githubusercontent.com/Mar-7th/StarRailRes/master"
def __init__(self, language: Language = Language.CHT): def __init__(self, language: Language = Language.CHT):
self.lang = language self.lang = language
@ -69,7 +71,6 @@ class MihomoAPI:
""" """
url = self.BASE_URL + "/" + str(uid) url = self.BASE_URL + "/" + str(uid)
if language != Language.CHS:
params.update({"lang": language.value}) params.update({"lang": language.value})
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
@ -83,7 +84,9 @@ class MihomoAPI:
except: except:
raise InvalidParams() raise InvalidParams()
else: else:
if isinstance(data, dict) and (detail := data.get("detail")): if isinstance(data, dict) and (
detail := data.get("detail")
):
raise InvalidParams(detail) raise InvalidParams(detail)
raise InvalidParams() raise InvalidParams()
case 404: case 404: