Browse Source

new structure, better code

main
Sergio Álvarez 4 months ago
parent
commit
ab54e91bad
  1. 13
      blizzard.py
  2. 9
      config.py
  3. 40
      spec.py

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

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

40
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},
]
Loading…
Cancel
Save