Skip to content

Instantly share code, notes, and snippets.

@craigcalef
Created September 1, 2013 09:28
Show Gist options
  • Save craigcalef/6403297 to your computer and use it in GitHub Desktop.
Save craigcalef/6403297 to your computer and use it in GitHub Desktop.
Access the EVE Online CREST API to obtain information on Dust 514 Planetary Conquest districts and produce reports of various useful information.
import requests, json
from collections import Counter
districts = json.loads(requests.get('http://public-crest.eveonline.com/districts/').text)['items']
systems = {}
constellations = {}
s_times = {}
c_times = {}
for d in districts:
if d['attacked']:
system = d['system']['name']
if system in systems.keys():
systems[system].append(d)
else:
systems[system] = [d]
constellation = d['constellation']['name']
if constellation in constellations.keys():
constellations[constellation].append(d)
else:
constellations[constellation] = [d]
sys_items = [(k, len(v)) for k,v in systems.items()]
sys_items.sort(key=lambda x: x[1], reverse=True)
consti_items = [(k, len(v)) for k,v in constellations.items()]
consti_items.sort(key=lambda x: x[1], reverse=True)
for n,dl in systems.items():
if not n in s_times.keys():
s_times[n] = Counter([i['reinforce'] for i in dl])
for n,dl in constellations.items():
if not n in c_times.keys():
c_times[n] = Counter([i['reinforce'] for i in dl])
for i in consti_items:
print i[0], ": ", i[1]
t = c_times[i[0]].items()
t.sort(key=lambda x: x[1], reverse=True)
for q in t:
print "\t", q[0], ": ", q[1]
teams = ["%s@%s" % (z['owner']['name'], z['name']) for z in filter(lambda x: x['reinforce'] == q[0], constellations[i[0]])]
print "\t\t", ", ".join(teams)
print "---"
for i in sys_items:
print i[0], ": ", i[1]
t = s_times[i[0]].items()
t.sort(key=lambda x: x[1], reverse=True)
for q in t:
print "\t", q[0], ": ", q[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment