This commit is contained in:
nyyu 2018-06-03 13:38:05 +02:00
parent abe74b7812
commit 52e1bf5c4b

View file

@ -17,6 +17,8 @@ ITEMS_TYPE = {
'Most Frequent Core Build': ['items', 'mostGames'], 'Most Frequent Core Build': ['items', 'mostGames'],
'Highest Win % Core Build': ['items', 'highestWinPercent'], 'Highest Win % Core Build': ['items', 'highestWinPercent'],
} }
CONSUMABLES = [2003, 2004, 2055, 2031, 2032, 2033, 2138, 2140, 2139]
TRINKETS = [3340, 3364, 3363]
def getChampData(champ, position): def getChampData(champ, position):
page = requests.get('https://champion.gg/champion/%s/%s?league=' % (champ, position), headers=HEADERS).text page = requests.get('https://champion.gg/champion/%s/%s?league=' % (champ, position), headers=HEADERS).text
@ -65,11 +67,11 @@ def writeItemSet(id, pos, ver, dir):
if path[1] in data[path[0]]: if path[1] in data[path[0]]:
item_set['blocks'].append(makeItemSet(data[path[0]][path[1]], label)) item_set['blocks'].append(makeItemSet(data[path[0]][path[1]], label))
item_set['blocks'].append(makeItemSetFromList([2003, 2004, 2055, 2031, 2032, 2033, 2138, 2140, 2139], "Consumables | Frequent: %s", 'mostGames', data)) item_set['blocks'].append(makeItemSetFromList(CONSUMABLES, "Consumables | Frequent: %s", 'mostGames', data))
item_set['blocks'].append(makeItemSetFromList([3340, 3364, 3363], "Trinkets | Wins: %s", 'highestWinPercent', data)) item_set['blocks'].append(makeItemSetFromList(TRINKETS, "Trinkets | Wins: %s", 'highestWinPercent', data))
logging.info('Writing item set for %s at %s' % (id, pos)) logging.info('Writing item set for %s at %s' % (id, pos))
with open('%sCGG_%s_%s.json' % (dir, id, pos), 'w', newline='\n') as out: with open(dir.joinpath('CGG_%s_%s.json' % (id, pos)), 'w', newline='\n') as out:
json.dump(item_set, out, indent=4) json.dump(item_set, out, indent=4)
def main(): def main():
@ -93,8 +95,8 @@ def main():
for name, positions in champ.items(): for name, positions in champ.items():
c = next((x for x in lol_champs if x['name'] == name), None) c = next((x for x in lol_champs if x['name'] == name), None)
if c is not None: if c is not None:
path = '%s%s\\Recommended\\' % (LOL_CHAMPS_DIR, c['id']) path = Path(LOL_CHAMPS_DIR, c['id'], 'Recommended')
Path(path).mkdir(parents=True, exist_ok=True) path.mkdir(parents=True, exist_ok=True)
for pos in positions: for pos in positions:
writeItemSet(c['id'], pos, patch, path) writeItemSet(c['id'], pos, patch, path)
sleep(.3) sleep(.3)