RATP: Keep using ratp.p0m.fr to get schedules

This commit is contained in:
nemunaire 2023-01-16 02:27:23 +01:00
parent 9dd2cc5624
commit 20916e60d1
1 changed files with 4 additions and 4 deletions

View File

@ -92,7 +92,7 @@ class IDFMAPI:
cache_file = self._cached_file % ("schedule-" + mode + "-" + line + "-" + hashlib.md5((mode + line + station + way).encode()).hexdigest())
req = urllib.request.Request(self.baseurl + "/stop-monitoring?MonitoringRef=STIF:StopPoint:Q:" + IDFMAPI.stops[mode][line][station] + ":", headers={'apikey': self.apikey})
req = urllib.request.Request("https://ratp.p0m.fr/api/schedules/%s/%s/%s/%s" % (mode, line, station, way))
try:
with urllib.request.urlopen(req) as f:
with open(cache_file, 'wb') as fd:
@ -108,7 +108,7 @@ class IDFMAPI:
res = json.load(f)
# Convert time to hours
now = datetime.fromisoformat(res["_metadata"]["date"])
now = datetime.fromisoformat(res["_metadata"]["date"] if len(res["_metadata"]["date"]) <= 25 else res["_metadata"]["date"][0:19] + res["_metadata"]["date"][len(res["_metadata"]["date"])-6:])
for i in range(len(res["result"]["schedules"])):
if "message" in res["result"]["schedules"][i]:
@ -294,10 +294,10 @@ class RATPNextStopModule:
api = IDFMAPI(config)
for stop in stops:
tmp = stop.split("/")
tmp = stop.split("/", 2)
mode = tmp[0][0]
line = tmp[0][1:]
if 1 < len(tmp) < 3:
if 1 < len(tmp) < 4:
prep = {}
for s in api.get_schedules(mode, line, *tmp[1:]):
if s["destination"] not in prep: