new structure, better code

This commit is contained in:
Sergio Álvarez 2021-05-14 00:33:52 +02:00
parent 1bae11f389
commit ab54e91bad
3 changed files with 62 additions and 0 deletions

13
blizzard.py Normal file
View File

@ -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(':'))

9
config.py Normal file
View File

@ -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')

40
spec.py Normal file
View File

@ -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},
]