summaryrefslogtreecommitdiffhomepage
path: root/scrap.py
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-05-25 18:48:11 +0200
committerAki <please@ignore.pl>2022-05-25 18:48:11 +0200
commit286d663f05c03b56b6510080db806794b4891150 (patch)
treed5f3e20b7582c3e0cbac5f5abe4ec3aa5048b05b /scrap.py
parent287450f0e9a237c55d64e493984a419908139b3d (diff)
downloadsalvager-286d663f05c03b56b6510080db806794b4891150.zip
salvager-286d663f05c03b56b6510080db806794b4891150.tar.gz
salvager-286d663f05c03b56b6510080db806794b4891150.tar.bz2
Added type details and moved esi stuff to own module
Diffstat (limited to 'scrap.py')
-rw-r--r--scrap.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/scrap.py b/scrap.py
index dc10eb5..2939451 100644
--- a/scrap.py
+++ b/scrap.py
@@ -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 {}