|
6 | 6 |
|
7 | 7 | query_url_name = "https://www.mvg.de/api/fahrinfo/location/queryWeb?q={name}" # for station names |
8 | 8 | query_url_id = "https://www.mvg.de/api/fahrinfo/location/query?q={id}" # for station ids |
9 | | -departure_url = "https://www.mvg.de/api/fahrinfo/departure/{id}?footway=0" |
| 9 | +departure_url = "https://www.mvg.de/api/fahrinfo/departure/{id}?footway={offset}" |
10 | 10 | nearby_url = "https://www.mvg.de/api/fahrinfo/location/nearby?latitude={lat}&longitude={lon}" |
11 | 11 | routing_url = "https://www.mvg.de/api/fahrinfo/routing/?" |
12 | 12 | interruptions_url = "https://www.mvg.de/.rest/betriebsaenderungen/api/interruptions" |
@@ -308,8 +308,9 @@ def get_route(start, dest, |
308 | 308 | return results["connectionList"] |
309 | 309 |
|
310 | 310 |
|
311 | | -def get_departures(station_id): |
312 | | - """Get the next departures for `station_id`. |
| 311 | +def get_departures(station_id, timeoffset=0): |
| 312 | + """Get the next departures for `station_id`. Optionally, define `timeoffset` |
| 313 | + to not show departures sooner than a number of minutes. |
313 | 314 |
|
314 | 315 | Change in 1.3.2: accepts both 'old-style' integer IDs which were used |
315 | 316 | by the API before this version and the new string IDs which |
@@ -343,7 +344,7 @@ def get_departures(station_id): |
343 | 344 | raise TypeError("Please give the int station_id of the station.\ |
344 | 345 | You can find it out by running \ |
345 | 346 | get_id_for_station('Station name')") |
346 | | - url = departure_url.format(id=station_id) |
| 347 | + url = departure_url.format(id=station_id, offset=timeoffset) |
347 | 348 | departures = _perform_api_request(url)['departures'] |
348 | 349 | for departure in departures: |
349 | 350 | # For some reason, mvg gives you a Unix timestamp, but in milliseconds. |
@@ -386,8 +387,8 @@ def __init__(self, station): |
386 | 387 | self.latitude = matching_stations[0]["latitude"] |
387 | 388 | self.longitude = matching_stations[0]["longitude"] |
388 | 389 |
|
389 | | - def get_departures(self): |
390 | | - return get_departures(self.id) |
| 390 | + def get_departures(self, timeoffset=0): |
| 391 | + return get_departures(self.id, timeoffset) |
391 | 392 |
|
392 | 393 | def __repr__(self): |
393 | 394 | return "Station(id=%s, name='%s')" % (self.id, self.name) |
0 commit comments