summaryrefslogtreecommitdiffhomepage
path: root/scrap.py
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-05-25 00:18:56 +0200
committerAki <please@ignore.pl>2022-05-25 00:18:56 +0200
commit9dfaa42565692b31a028ec92372fa675da4f3e21 (patch)
tree1153beb81762a7f4d8275b04e7d217573bf3dda8 /scrap.py
parentdc25a785bbb41d4f375d520235e3d9629905f3f2 (diff)
downloadsalvager-9dfaa42565692b31a028ec92372fa675da4f3e21.zip
salvager-9dfaa42565692b31a028ec92372fa675da4f3e21.tar.gz
salvager-9dfaa42565692b31a028ec92372fa675da4f3e21.tar.bz2
Killmails' details are now expanded
Diffstat (limited to 'scrap.py')
-rw-r--r--scrap.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/scrap.py b/scrap.py
index c985e8c..84c2b2d 100644
--- a/scrap.py
+++ b/scrap.py
@@ -88,8 +88,32 @@ def expand_hashes(snapshot):
Expands killmails in *snapshot* IN PLACE by adding their hash based on information from Zkillboard.
"""
for killmail in snapshot["killmails"]:
- killmail["hash"] = get_hash(killmail["id"])
time.sleep(1.05) # Zkillboard is very sensitive.
+ killmail["hash"] = get_hash(killmail["id"])
+ 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['id'], killmail['hash'])
+ del details['attackers']
+ del details['victim']['items']
+ del details['victim']['damage_taken']
+ killmail.update(details)
return snapshot
@@ -113,6 +137,7 @@ def main():
args = parser.parse_args()
snapshot = get_related_kills(args.url)
expand_hashes(snapshot)
+ expand_details(snapshot)
filename = output_name(args)
with open(filename, "w") as fd:
opts = {'indent': 4} if args.pretty else {}