diff options
Diffstat (limited to 'scrap.py')
-rw-r--r-- | scrap.py | 23 |
1 files changed, 9 insertions, 14 deletions
@@ -7,6 +7,8 @@ from html.parser import HTMLParser import requests +from salvager import esi + OWNER_HREF = re.compile(r"/(?:corporation|alliance)/(\d+)/?") SYSTEM_AND_DATE = re.compile(r"/(\d+)/(\d+)/?$") @@ -90,30 +92,22 @@ def expand_hashes(snapshot): return snapshot -def get_details(kill, hash): - """ - Retrieves detailed information about killmail from EVE ESI using killmail's *kill* ID and *hash*. - """ - query = "https://esi.evetech.net/latest/killmails/{}/{}/?datasource=tranquility" - response = requests.get(query.format(kill, hash)) - response.raise_for_status() - return response.json() - - def expand_details(snapshot): """ Expands killmails in *snapshot* IN PLACE by adding details from EVE ESI. Some data is dropped in process as e.g., full information on attackers is not important in context of the visualizations. """ for killmail in snapshot['killmails']: - details = get_details(killmail['killmail_id'], killmail['hash']) - del details['attackers'] - del details['victim']['items'] - del details['victim']['damage_taken'] + details = esi.killmail(killmail['killmail_id'], killmail['hash']) killmail.update(details) return snapshot +def get_ships(snapshot): + ships = {x['victim']['ship_type_id'] for x in snapshot['killmails']} + return [esi.type(x) for x in ships] + + def output_name(args): """ Generates name of the output file based on the CLI *args*. @@ -135,6 +129,7 @@ def main(): snapshot = get_related_kills(args.url) expand_hashes(snapshot) expand_details(snapshot) + snapshot['ships'] = get_ships(snapshot) filename = output_name(args) with open(filename, 'w') as fd: opts = {'indent': 4} if args.pretty else {} |