Skip too close transports

This commit is contained in:
nemunaire 2023-09-06 10:21:34 +02:00
parent 0951369742
commit a14edacb0e
1 changed files with 10 additions and 0 deletions

View File

@ -378,6 +378,8 @@ class RATPNextStopModule:
align = 0
mint = datetime.now() + timedelta(minutes=10)
api = IDFMAPI(config)
for stop in stops:
tmp = stop.split("/", 2)
@ -387,6 +389,14 @@ class RATPNextStopModule:
if 1 < len(tmp) < 4:
prep = {}
for s in api.get_schedules(mode, line, *tmp[1:]):
# Skip too close items
try:
t = datetime.strptime(datetime.now().strftime("%Y-%m-%dT") + s["message"][0:5], "%Y-%m-%dT%H:%M")
if t < mint:
continue
except:
pass
if s["destination"] not in prep:
prep[s["destination"]] = []
prep[s["destination"]].append(s)