Ajout des cars et des train sur infotbm
Le site a ajouté les cars et les trains, mais ces nouvelles lignes n'ont pas de suivi en temps réel. Il a fallu ajouter du code pour ne pas les intégrer dans les données récupérées. Pour le moment, le Bat³ n'est pas visible. J'ai également modifié le code pour balayer plus de cas dans le test.
This commit is contained in:
parent
1cbcbe3e75
commit
2df827d3ad
25
stop.py
25
stop.py
|
@ -11,6 +11,14 @@ search_stop_url = 'https://ws.infotbm.com/ws/1.0/get-schedule/%s'
|
||||||
stop_info_url = 'https://ws.infotbm.com/ws/1.0/network/stoparea-informations/%s'
|
stop_info_url = 'https://ws.infotbm.com/ws/1.0/network/stoparea-informations/%s'
|
||||||
stop_schedule_url = 'https://ws.infotbm.com/ws/1.0/get-realtime-pass/%d/%s'
|
stop_schedule_url = 'https://ws.infotbm.com/ws/1.0/get-realtime-pass/%d/%s'
|
||||||
|
|
||||||
|
line_types = (
|
||||||
|
'Tram',
|
||||||
|
'Corol',
|
||||||
|
'Lianes',
|
||||||
|
'Ligne',
|
||||||
|
'Bus Relais',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def search_stop_by_name (keyword):
|
def search_stop_by_name (keyword):
|
||||||
'''
|
'''
|
||||||
|
@ -85,11 +93,20 @@ def show_stops_from_ref (ref):
|
||||||
'terminus': j ['name'],
|
'terminus': j ['name'],
|
||||||
'line_human': j ['line'] ['name'],
|
'line_human': j ['line'] ['name'],
|
||||||
}
|
}
|
||||||
|
try:
|
||||||
line_id = search ('[0-9A-D]+$', rte ['line_human']).group ()
|
line_id = search ('[0-9A-D]+$', rte ['line_human']).group ()
|
||||||
|
except AttributeError:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
line_id = '%02d' % int (line_id)
|
line_id = '%02d' % int (line_id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
a = False
|
||||||
|
for i in line_types:
|
||||||
|
if rte ['line_human'] [0:len (i)] == i:
|
||||||
|
a = True
|
||||||
|
break
|
||||||
|
if a:
|
||||||
rte ['line_id'] = line_id
|
rte ['line_id'] = line_id
|
||||||
s ['routes'].append (rte)
|
s ['routes'].append (rte)
|
||||||
r ['stop_points'].append (s)
|
r ['stop_points'].append (s)
|
||||||
|
@ -130,7 +147,11 @@ class StopRoute ():
|
||||||
'''
|
'''
|
||||||
Met à jour les données
|
Met à jour les données
|
||||||
'''
|
'''
|
||||||
d = get_data_from_json (stop_schedule_url % (self.number, self.line)) ['destinations']
|
d = get_data_from_json (stop_schedule_url % (self.number, self.line))
|
||||||
|
if 'destinations' in d:
|
||||||
|
d = d ['destinations']
|
||||||
|
else:
|
||||||
|
return ()
|
||||||
self.last_update = time ()
|
self.last_update = time ()
|
||||||
if type (d) == dict:
|
if type (d) == dict:
|
||||||
self.data = []
|
self.data = []
|
||||||
|
@ -196,7 +217,7 @@ class StopRoute ():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
for word in ('Gravière', 'Stade Chaban Delmas', 'Cassagne', 'Zorbut'):
|
for word in ('Gravière', 'Gare Saint Jean', 'Quinconces', 'Zorbut'):
|
||||||
print (word + ':')
|
print (word + ':')
|
||||||
for area in search_stop_by_name (word):
|
for area in search_stop_by_name (word):
|
||||||
print ('\t' + area ['name'] + ' (' + area ['city'] + '):')
|
print ('\t' + area ['name'] + ' (' + area ['city'] + '):')
|
||||||
|
|
Loading…
Reference in New Issue