blizzard-wow-game-data-apis/blizzard.py

17 lines
618 B
Python
Raw Permalink Normal View History

2021-05-13 22:33:52 +00:00
import os
from typing import Tuple
def get_api_host(region: str) -> str:
return f"https://{region}.api.blizzard.com" if region != 'cn' else 'https://gateway.battlenet.com.cn'
def get_bnet_host(region: str) -> str:
region = region if region not in ['tw', 'kr'] else 'apac'
return f"https://{region}.battle.net" if region != 'cn' else 'https://www.battlenet.com.cn'
def get_credentials(path: str) -> Tuple[str, str]:
return tuple(open(os.path.join(path, '.credentials')).read().strip().split(':'))
2021-05-14 02:16:23 +00:00
def get_by_key(values: list, key: str, value):
return next(x for x in values if x[key] == value)