import json import sys import requests import re import random import aiohttp import asyncio import os class Champion: Name: str Role: [str] def __init__(self, name: str, roles: [str]): self.Name = name self.Role = roles Lanes = ["Top", "Mid", "Bot", "Support", "Jgl"] async def fetch_champion(session, url_entry): try: async with session.get(url_entry, timeout=5) as resp: data = await resp.json() if data.get("name") == "None": return None return Champion(data["name"], data["roles"]) except Exception as e: print(f'Could not get {url_entry}: {e}') return None async def get_champions_async(base_url: str, sub_urls: [str]) -> [Champion]: champions = [] async with aiohttp.ClientSession() as session: tasks = [] for entry in sub_urls: full_url = f'{base_url}/{entry}' tasks.append(fetch_champion(session, full_url)) results = await asyncio.gather(*tasks) for champ in results: if champ is not None: champions.append(champ) return champions def get_player_list() -> [Champion]: url = "https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champions" response = requests.get(url) data = response.text data = data[data.index('id="list"')::] data = data[data.index("