Make arrival detection more flexible for stations with multiple names

This commit is contained in:
Julian Metzler 2022-03-19 13:31:47 +01:00
parent d2c2797afc
commit fe24cfa193
1 changed files with 4 additions and 4 deletions

8
run.py
View File

@ -20,7 +20,7 @@ def route_from(route, station):
new_route = []
for stop in route:
if not start_found:
start_found = stop == station
start_found = stop.startswith(station)
if start_found:
new_route.append(stop)
return new_route
@ -54,7 +54,7 @@ def update_display(display, dbi):
if train_type == "RE":
display.info_2.set(NO_STOP_EVERYWHERE_TEXT)
is_arrival = train['destination'] == STATION_NAME
is_arrival = train['destination'].startswith(STATION_NAME)
#if train['platform'] != PLATFORM:
# platform = int("".join(c for c in train['platform'] if c.isdigit()))
@ -73,7 +73,7 @@ def update_display(display, dbi):
delay = dbi.round_delay(train['delayArrival']) if train['delayArrival'] else 0
delay_raw = train['delayArrival'] or 0
if train['destination'] == STATION_NAME:
if train['destination'].startswith(STATION_NAME):
display.info_2.set(DO_NOT_BOARD_TEXT)
if train['isCancelled']:
@ -102,7 +102,7 @@ def update_display(display, dbi):
display.via_1.set(MAP_VIA_1[via_code_1])
display.via_2.set(MAP_VIA_2[via_code_2])
if train['destination'] == STATION_NAME:
if is_arrival:
text = "von " + ARRIVAL_MAP.get(train['route'][0]['name'], train['route'][0]['name']).replace("ß", "ss")
text = text.rstrip("Hbf").strip()
display.destination.set(text)