ratp: Handle more situations
This commit is contained in:
parent
268f6350d5
commit
2fc0f44de9
@ -92,17 +92,17 @@ class IDFMAPI:
|
||||
res = json.load(f)
|
||||
|
||||
# Convert time to hours
|
||||
if mode != "rers":
|
||||
now = datetime.fromisoformat(res["_metadata"]["date"])
|
||||
now = datetime.fromisoformat(res["_metadata"]["date"])
|
||||
|
||||
for i in range(len(res["result"]["schedules"])):
|
||||
if "message" in res["result"]["schedules"][i]:
|
||||
if res["result"]["schedules"][i]["message"] == "A l'approche" or res["result"]["schedules"][i]["message"] == "A l'arret":
|
||||
res["result"]["schedules"][i]["message"] = now.strftime("%H:%M")
|
||||
elif res["result"]["schedules"][i]["message"].endswith(" mn"):
|
||||
res["result"]["schedules"][i]["message"] = (now + timedelta(minutes=int(res["result"]["schedules"][i]["message"].split(" ")[0]))).strftime("%H:%M")
|
||||
for i in range(len(res["result"]["schedules"])):
|
||||
if "message" in res["result"]["schedules"][i]:
|
||||
if res["result"]["schedules"][i]["message"] == "Train a l'approche" or res["result"]["schedules"][i]["message"] == "Train à l'approche" or res["result"]["schedules"][i]["message"] == "Train à quai" or res["result"]["schedules"][i]["message"] == "Train a quai" or res["result"]["schedules"][i]["message"] == "A l'approche" or res["result"]["schedules"][i]["message"] == "A l'arret":
|
||||
res["result"]["schedules"][i]["message"] = now.strftime("%H:%M")
|
||||
elif res["result"]["schedules"][i]["message"].endswith(" mn"):
|
||||
res["result"]["schedules"][i]["message"] = (now + timedelta(minutes=int(res["result"]["schedules"][i]["message"].split(" ")[0]))).strftime("%H:%M")
|
||||
res["result"]["schedules"][i]["message"] = res["result"]["schedules"][i]["message"].replace(" Retardé", "+").replace("Train retardé", "...")
|
||||
|
||||
return res["result"]["schedules"]
|
||||
return [m for m in res["result"]["schedules"] if "message" in m and m["message"] != "Train sans arrêt"]
|
||||
|
||||
def get_weather(self):
|
||||
ret = {}
|
||||
@ -278,6 +278,9 @@ class RATPNextStopModule:
|
||||
|
||||
max_dest = 64
|
||||
for dest, msgs in prep.items():
|
||||
if len(msgs) == 0:
|
||||
continue
|
||||
|
||||
align_x = line_height * 2
|
||||
|
||||
sz = fnt_B.getsize(dest)[0]
|
||||
|
Loading…
Reference in New Issue
Block a user