v4, Origin Icao + name
This commit is contained in:
parent
f542fdeb70
commit
8e8a98bbd0
1 changed files with 15 additions and 2 deletions
|
|
@ -24,18 +24,30 @@ def aircr_name(aircraft_icao):
|
|||
antwort = "unbekanntes Luftfahrzeug"
|
||||
return (antwort)
|
||||
|
||||
def start_name(ori_icao):
|
||||
|
||||
with open("airports_full.json", "r", encoding="utf-8") as f:
|
||||
ori_data = json.load(f)
|
||||
if ori_icao in ori_data:
|
||||
antwort = (ori_data[ori_icao]["name"])
|
||||
else:
|
||||
print("Code nicht vorhanden")
|
||||
antwort = "unbekannter Startflughafen"
|
||||
return (antwort)
|
||||
|
||||
resp = requests.get(URL, params=params, timeout=15)
|
||||
|
||||
resp.raise_for_status()
|
||||
|
||||
data = resp.json() # dict
|
||||
|
||||
# Überblick verschaffen: Top-Level-Keys ausgeben
|
||||
# Top-Level-Keys ausgeben
|
||||
print(data.keys())
|
||||
print()
|
||||
|
||||
# Typische Bereiche (abhängig von deinem Flugplan):
|
||||
general = data.get("general", {})
|
||||
origin = data.get("origin", {})
|
||||
origin_name = start_name(origin["icao_code"])
|
||||
dest = data.get("destination", {})
|
||||
aircraft = data.get("aircraft", {})
|
||||
time = data.get("times", {})
|
||||
|
|
@ -49,3 +61,4 @@ print("Abflug ICAO:", origin.get("icao_code"))
|
|||
print("Ziel ICAO:", dest.get("icao_code"))
|
||||
print("Geplante Blockzeit:", block)
|
||||
print(aircraft_icao, aircraft_name)
|
||||
print(origin["icao_code"], origin_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue