From 01cbe84ff290dba3ae41c32b0cb9297da6c9c955 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Mon, 9 Feb 2026 13:01:17 +0100 Subject: [PATCH] fix: patch MatchRider stop handling * IFOPTS don't require a matchrider prefix * area/quai part is removed from ifopt * default name "-" is set if non is specified --- amarillo/services/importing/matchrider.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/amarillo/services/importing/matchrider.py b/amarillo/services/importing/matchrider.py index b86f15d..62336f1 100644 --- a/amarillo/services/importing/matchrider.py +++ b/amarillo/services/importing/matchrider.py @@ -13,7 +13,14 @@ def __init__(self, url, http_headers): @staticmethod def _extract_stop(stop): - stop_id = f'matchrider:{stop["id"]}' if not stop['id'].startswith('matchrider:') else stop['id'] + if stop['id'].startswith('matchrider:'): + stop_id = stop['id'] + else: + # if stop id does not start with matchrider:, + # we expect ifopt. However, only station ifopt + # is currently supported, so we chop off trailing parts + stop_id = stop['id'][0:stop['id'].find(':',9)] + stop_name = stop.get('name','-') arrivalTime = stop.get('arrivalTime') departureTime = stop.get('departureTime') if arrivalTime is not None and len(arrivalTime)==5: @@ -23,7 +30,7 @@ def _extract_stop(stop): return StopTime( id=stop_id, - name=stop['name'], + name=stop_name, lat=float(stop['lat']), lon=float(stop['lon']), arrivalTime=arrivalTime, @@ -49,9 +56,6 @@ def _get_data_from_json_response(self, json_response): for cp in payload: if self._should_offer_be_ignored(cp): continue - for stop in cp['stops']: - if 'id' in stop and not stop['id'].startswith('matchrider:'): - stop['id'] = f'matchrider:{stop["id"]}' - + filtered_payload.append(cp) return filtered_payload