123456789101112131415161718192021222324252627282930313233343536 |
- import json
- from datetime import datetime, timedelta
- def s2t(seconds):
- h = seconds//3600
- m = seconds%3600//60
- s = (seconds%3600)%60
- return "{:02.0f}:{:02.0f}:{:02.0f}".format(h, m, s)
- f = open("mrzmay.json", "r")
- members = json.loads(f.read())
- f.close()
- dateformat = "%Y-%m-%dT%H:%M:%SZ"
- stations = ['EDWW_M__CTR', 'EDUU_O_CTR', 'EDWW_MRZ_CTR', 'EDWW__M_CTR', 'EDWW_M___CTR', 'EDWW_B___CTR', 'EDWW_CTR', 'EDWW_B_CTR', 'EDWW_M_CTR', 'EDWW_B__CTR', 'EDWW_F_CTR', 'EDWW_K_CTR']
- for member in members:
- member["eval"] = {"sessions": 0, "time": timedelta(seconds=0), "aircraft": 0}
- for item in member["data"]["items"]:
- if datetime.strptime(item["connection_id"]["start"],dateformat) > datetime.strptime("2024-05-01T00:00:00Z",dateformat) and item["connection_id"]["callsign"] in stations:
- member["eval"]["sessions"] += 1
- member["eval"]["time"] += (datetime.strptime(item["connection_id"]["end"], dateformat) - datetime.strptime(item["connection_id"]["start"], dateformat))
- member["eval"]["aircraft"] += item["aircrafttracked"]
- print("{:>7}: Sessions: {:>3}, Online für: {}, Flugzeuge: {:>4}".format(member["name"], member["eval"]["sessions"], s2t(member["eval"]["time"].total_seconds()), member["eval"]["aircraft"]))
- totals ={"sessions": 0, "time": timedelta(seconds=0), "aircraft": 0}
- for member in members:
- totals["sessions"] += member["eval"]["sessions"]
- totals["time"] += member["eval"]["time"]
- totals["aircraft"] += member["eval"]["aircraft"]
- print("=============================================================")
- print("{:>7}: Sessions: {:>3}, Online für: {}, Flugzeuge: {:>4}".format("Gesamt", totals["sessions"], s2t(totals["time"].total_seconds()), totals["aircraft"]))
|