async def get_blob(ctx: HTTPRequestContext, battletag: str): """ Returns a giant blob of data. """ pages = await fetch_all_user_pages(ctx, battletag, platform=ctx.request.args.get("platform", "pc")) built_dict = {} for region, result in pages.items(): if result is None: built_dict[region] = None continue d = { "heroes": {"playtime": {"competitive": {}, "quickplay": {}}, "stats": {"competitive": {}, "quickplay": {}}}, "stats": {}, "achievements": {} } d["stats"]["quickplay"] = parsing.bl_parse_stats(result) d["stats"]["competitive"] = parsing.bl_parse_stats(result, mode="competitive") d["heroes"]["stats"]["quickplay"] = parsing.bl_parse_hero_data(result) d["heroes"]["playtime"]["quickplay"] = parsing.bl_parse_all_heroes(result) d["heroes"]["stats"]["competitive"] = parsing.bl_parse_hero_data(result, mode="competitive") d["heroes"]["playtime"]["competitive"] = parsing.bl_parse_all_heroes(result, mode="competitive") d["achievements"] = parsing.bl_parse_achievement_data(result) built_dict[region] = d return built_dict
async def get_blob(ctx: HTTPRequestContext, battletag: str): """ Returns a giant blob of data. """ pages = await fetch_all_user_pages(ctx, battletag, platform=ctx.request.args.get("platform", "pc")) built_dict = {} for region, result in pages.items(): if result is None: built_dict[region] = None continue d = { "heroes": {"playtime": {"competitive": {}, "quickplay": {}}, "stats": {"competitive": {}, "quickplay": {}}}, "stats": {}, "achievements": {}} d["stats"]["quickplay"] = parsing.bl_parse_stats(result) d["stats"]["competitive"] = parsing.bl_parse_stats(result, mode="competitive") d["heroes"]["stats"]["quickplay"] = parsing.bl_parse_hero_data(result) d["heroes"]["playtime"]["quickplay"] = parsing.bl_parse_all_heroes(result) d["heroes"]["stats"]["competitive"] = parsing.bl_parse_hero_data(result, mode="competitive") d["heroes"]["playtime"]["competitive"] = parsing.bl_parse_all_heroes(result, mode="competitive") d["achievements"] = parsing.bl_parse_achievement_data(result) built_dict[region] = d return built_dict
async def get_heroes(ctx: HTTPRequestContext, battletag: str): """ Fetches hero stats, in one big blob. """ pages = await fetch_all_user_pages(ctx, battletag, platform=ctx.request.args.get("platform", "pc")) built_dict = {} for region, result in pages.items(): if result is None: built_dict[region] = None continue status = result.xpath(".//p[@class='masthead-permission-level-text']")[0].text if status == "Private Profile": return {"error": "Private"}, 403 d = { "heroes": {"playtime": {"competitive": {}, "quickplay": {}}, "stats": {"competitive": {}, "quickplay": {}}}, } d["heroes"]["stats"]["quickplay"] = parsing.bl_parse_hero_data(result) d["heroes"]["playtime"]["quickplay"] = parsing.bl_parse_all_heroes(result) d["heroes"]["stats"]["competitive"] = parsing.bl_parse_hero_data(result, mode="competitive") d["heroes"]["playtime"]["competitive"] = parsing.bl_parse_all_heroes(result, mode="competitive") built_dict[region] = d return built_dict
async def get_blob(ctx: HTTPRequestContext, battletag: str): """ Returns a giant blob of data. """ pages = await fetch_all_user_pages(ctx, battletag, platform=ctx.request.args.get( "platform", "pc")) built_dict = {} for region, result in pages.items(): if result is None: built_dict[region] = None continue status = result.xpath( ".//p[@class='masthead-permission-level-text']")[0].text if "private" in status.lower(): return {"error": "Private"}, 403 d = { "heroes": { "playtime": { "competitive": {}, "quickplay": {} }, "stats": { "competitive": {}, "quickplay": {} } }, "stats": {}, "achievements": {} } d["stats"]["quickplay"] = parsing.bl_parse_stats(result, status=status) d["stats"]["competitive"] = parsing.bl_parse_stats(result, mode="competitive", status=status) d["heroes"]["stats"]["quickplay"] = parsing.bl_parse_hero_data(result) d["heroes"]["playtime"]["quickplay"] = parsing.bl_parse_all_heroes( result) d["heroes"]["stats"]["competitive"] = parsing.bl_parse_hero_data( result, mode="competitive") d["heroes"]["playtime"]["competitive"] = parsing.bl_parse_all_heroes( result, mode="competitive") d["achievements"] = parsing.bl_parse_achievement_data(result) built_dict[region] = d return built_dict
async def get_heroes_qp(ctx: HTTPRequestContext, battletag: str): """ Fetches hero stats, for quick-play. """ pages = await fetch_all_user_pages(ctx, battletag, platform=ctx.request.args.get( "platform", "pc")) built_dict = {} for region, result in pages.items(): if result is None: built_dict[region] = None continue d = { "heroes": { "playtime": { "competitive": {}, "quickplay": {} }, "stats": { "competitive": {}, "quickplay": {} } }, } d["heroes"]["stats"]["quickplay"] = parsing.bl_parse_hero_data(result) d["heroes"]["playtime"]["quickplay"] = parsing.bl_parse_all_heroes( result) built_dict[region] = d return built_dict
async def get_hero(ctx: HTTPRequestContext, hero: str): """ Send hero data for selected hero. """ parsed = await get_hero_data(ctx, hero) _hero = parsing.bl_parse_hero_data(parsed) _hero["name"] = hero return _hero
async def get_heroes(ctx: HTTPRequestContext): """ Send hero list. """ parsed = await get_all_heroes(ctx) heroes = parsing.bl_parse_all_heroes(parsed) built_dict = {"Offense": {}, "Defense": {}, "Tank": {}, "Support": {}} for hero in heroes: _parsed = await get_hero_data(ctx, hero.lower()) retHero = parsing.bl_parse_hero_data(_parsed) built_dict[retHero["role"]][hero] = retHero return built_dict
async def get_heroes_qp(ctx: HTTPRequestContext, battletag: str): """ Fetches hero stats, for quick-play. """ pages = await fetch_all_user_pages(ctx, battletag, platform=ctx.request.args.get("platform", "pc")) built_dict = {} for region, result in pages.items(): if result is None: built_dict[region] = None continue d = { "heroes": {"playtime": {"competitive": {}, "quickplay": {}}, "stats": {"competitive": {}, "quickplay": {}}}, } d["heroes"]["stats"]["quickplay"] = parsing.bl_parse_hero_data(result) d["heroes"]["playtime"]["quickplay"] = parsing.bl_parse_all_heroes(result) built_dict[region] = d return built_dict