diff --git a/run.py b/run.py index 83e630c..9d1d363 100644 --- a/run.py +++ b/run.py @@ -156,8 +156,18 @@ def update_display(display, dbi): text = text.rstrip("Hbf").strip() display.destination.set(text) else: - dest = filter_route(train['route'])[-1]['name'] - dest = re.sub(r"\(.*\)$", "", dest).strip() + # Check if the last stop matches the destination. + # For some international trains, the route stops at the border, + # but the destination is correct. + # This is different from cancelled stops, which do show up in the route, + # but with the "isCancelled" flag set." + if train['route'][-1] != train['destination']: + # Incomplete route, show actual destination + dest = train['destination'] + else: + # Normal route + dest = filter_route(train['route'])[-1]['name'] + dest = re.sub(r"\(.*\)$", "", dest).strip() # Filter out suffixes in parentheses text = DESTINATION_MAP.get(dest, dest).replace("ß", "ss") if train_type == "S": text = "".join(train['train'].split()) + " " + text