From ab54e91bad1a5862aa48e4757d9578bf5e518fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20=C3=81lvarez?= Date: Fri, 14 May 2021 00:33:52 +0200 Subject: [PATCH] new structure, better code --- blizzard.py | 13 +++++++++++++ config.py | 9 +++++++++ spec.py | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 blizzard.py create mode 100644 config.py create mode 100644 spec.py diff --git a/blizzard.py b/blizzard.py new file mode 100644 index 0000000..288c817 --- /dev/null +++ b/blizzard.py @@ -0,0 +1,13 @@ + +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(':')) diff --git a/config.py b/config.py new file mode 100644 index 0000000..9f608bf --- /dev/null +++ b/config.py @@ -0,0 +1,9 @@ + +import os + +# pwd +pwd = os.path.dirname(os.path.realpath(__file__)) +# raw json files +raw = os.path.join(pwd, 'raw') +# crafted jsons +craft = os.path.join(pwd, 'craft') diff --git a/spec.py b/spec.py new file mode 100644 index 0000000..b51d593 --- /dev/null +++ b/spec.py @@ -0,0 +1,40 @@ + +factions = ['alliance', 'horde'] + +""" +https://develop.battle.net/documentation/guides/regionality-and-apis +""" +regions = [ + {'code': 'us', 'locales': ['en_US', 'es_MX', 'pt_BR']}, + #{'code': 'eu', 'locales': ['en_GB', 'es_ES', 'fr_FR', 'ru_RU', 'de_DE', 'pt_PT', 'it_IT']}, + #{'code': 'kr', 'locales': ['ko_KR']}, + {'code': 'tw', 'locales': ['zh_TW']}, + #{'code': 'cn', 'locales': ['zh_CN']} +] + +""" +https://develop.battle.net/documentation/world-of-warcraft/game-data-apis +""" +apis = [ + {'path': '/data/wow/achievement-category/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/achievement/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/connected-realm/index', 'namespaces': ['dynamic', 'dynamic-classic'], 'index': True}, + {'path': '/data/wow/covenant/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/covenant/soulbind/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/covenant/conduit/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/creature-family/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/creature-type/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/item-class/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/item-set/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/journal-expansion/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/journal-encounter/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/journal-instance/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/modified-crafting/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/modified-crafting/category/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/modified-crafting/reagent-slot-type/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/mount/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/keystone-affix/index', 'namespaces': ['static'], 'index': True}, + {'path': '/data/wow/mythic-keystone/dungeon/index', 'namespaces': ['dynamic'], 'index': True}, + {'path': '/data/wow/mythic-keystone/index', 'namespaces': ['dynamic'], 'index': True}, + {'path': '/data/wow/mythic-keystone/period/index', 'namespaces': ['dynamic'], 'index': True}, +]