Skip to content

Instantly share code, notes, and snippets.

@bangingheads
Created November 22, 2021 15:25
Show Gist options
  • Save bangingheads/a6fe623f34264c63619de5fea16561dd to your computer and use it in GitHub Desktop.
Save bangingheads/a6fe623f34264c63619de5fea16561dd to your computer and use it in GitHub Desktop.
Script to grab champion play rates from cdragon in meraki format
import json
import re
import requests
all_champs = {}
data = requests.get("https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-champion-statistics/global/default/rcp-fe-lol-champion-statistics.js")
matches = re.findall('.exports=({.*)},', data.text)
if len(matches) > 0:
match = matches[0]
match = re.sub("([A-Z0-9]*):", r'"\1":', match)
match = re.sub("\.([0-9]*)", r'0.\1', match)
roles = json.loads(match)
champs = requests.get("https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-summary.json").json()
all_roles = ["TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY"]
all_champs = {str(champ['id']):{role:{"playRate": 0, "banRate": 0, "winRate": 0} for role in all_roles} for champ in champs if champ['id'] != -1}
for role in all_roles:
for champion, rate in roles["SUPPORT" if role == "UTILITY" else role].items():
all_champs[champion][role]['playRate'] = round(rate * 100, 5)
version_split = requests.get("https://raw.communitydragon.org/latest/content-metadata.json").json()["version"].split(".")
version = version_split[0] + "." + version_split[1]
with open("championrates.json", "w") as f:
json.dump({"data":all_champs,"patch":version}, f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment