mirror of
https://github.com/deesiigneer/pyspapi.git
synced 2026-04-20 12:35:26 +00:00
new feature get_uuids()
This commit is contained in:
@@ -197,24 +197,23 @@ class MojangAPI:
|
|||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# TODO: check, why always errorMessage return invalid
|
@classmethod
|
||||||
# @classmethod
|
def get_uuids(cls, names: List[str]) -> Dict[str, str]:
|
||||||
# def get_uuids(cls, names: List[str]) -> Dict[str, str]:
|
"""
|
||||||
# """
|
Получить UUID's игроков Minecraft.\n
|
||||||
# Получить UUID's игроков Minecraft.\n
|
:param names: List[str] Список с никнеймами игроков Minecraft.
|
||||||
# :param names: List[str] Список с никнеймами игроков Minecraft.
|
:return: Dict[str, str] UUID игрока Minecraft.
|
||||||
# :return: Dict[str, str] UUID игрока Minecraft.
|
|
||||||
#
|
"""
|
||||||
# """
|
if len(names) > 10:
|
||||||
# if len(names) > 10:
|
names = names[:10]
|
||||||
# names = names[:10]
|
response = cls.__make_request('API', 'POST', '/profiles/minecraft', data=names).json()
|
||||||
# response = cls.__make_request('API', 'POST', '/profiles/minecraft', data=names).json()
|
if not isinstance(response, list):
|
||||||
# if not isinstance(response, list):
|
if response.get('error'):
|
||||||
# if response.get('error'):
|
raise ValueError(response['errorMessage'])
|
||||||
# raise ValueError(response['errorMessage'])
|
else:
|
||||||
# else:
|
raise _Error(response)
|
||||||
# raise Error(response)
|
return {uuids['name']: uuids['id'] for uuids in response}
|
||||||
# return {uuids['name']: uuids['id'] for uuids in response}
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_username(cls, uuid: str) -> Optional[str]:
|
def get_username(cls, uuid: str) -> Optional[str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user