diff --git a/src/data/operators.py b/src/data/operators.py index 591052b..88fec47 100644 --- a/src/data/operators.py +++ b/src/data/operators.py @@ -26,7 +26,7 @@ OPERATORS = { "slogan": ["Senk ju vor träwelling wis Deutsche Bahn.", "Bitte beachten Sie die umgekehrte Wagenreihung.", "Zurückbleiben bitte!", "Alle reden vom Wetter. Wir nicht.", "Die Bahn macht mobil.", "Grün abgefahren"] }, "db_bawü": { - "logo": "https://upload.wikimedia.org/wikipedia/commons/d/d1/Bwegt_Logo_%282020%29.jpg", + "logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Bwegt_Logo.svg/960px-Bwegt_Logo.svg.png", "color": 0xFFBF34, "slogan": ["Nett hier", "Aber waren Sie schon mal in Baden-Württemberg?", "Bwegt euch!"] }, diff --git a/src/handlers.py b/src/handlers.py index 71ff9c2..32d6948 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -40,7 +40,7 @@ async def rename_vc(bot: discord.Bot): train_ID = current['train_number'] train_info = get_train_info(station=current['station'], train_ID=train_ID, train_type=train_type) - if train_info['operators'] and train_info['arrival']: + if train_info and train_info.get('operators') and train_info.get('arrival'): break logger(f"Versuch {attempt}: Keine Ankunftszeit für {current['train']} verfügbar, versuche neue Verbindung...") diff --git a/src/utils.py b/src/utils.py index 93af63b..fec64c4 100644 --- a/src/utils.py +++ b/src/utils.py @@ -68,7 +68,17 @@ def get_train_info(station, train_ID, train_type): return None dep = data.get("departure", []) - arrival_iso = dep.get("route_post_diff", [])[-1].get("sched_arr") + if not dep: + return None + + route_post = dep.get("route_post_diff") + if not route_post: + return None + + arrival_iso = route_post[-1].get("sched_arr") + if not arrival_iso: + return None + return { "arrival": arrival_iso, "operators": dep.get("operators"),