Browse Source

Also add the next bus departure

rorist 4 months ago
parent
commit
2d16a3a14a
1 changed files with 8 additions and 3 deletions
  1. 8 3
      screend.py

+ 8 - 3
screend.py

@@ -71,14 +71,19 @@ def power():
         time.sleep(1)
 
 def bus():
-    URL = 'https://transport.opendata.ch/v1/stationboard?id=8592223&limit=1&type=departure&transportations[]=bus'
+    limit = 2
+    URL = 'https://transport.opendata.ch/v1/stationboard?id=8592223&limit={}&type=departure&transportations[]=bus'.format(limit)
 
     while True:
         data = requests.get(URL).json()
-        ts = data['stationboard'][0]['stop']['departureTimestamp']
+        times = []
+        for i in range(limit):
+            _ts = data['stationboard'][i]['stop']['departureTimestamp']
+            _time = arrow.get(_ts).humanize()
+            times.append(_time)
 
         f = open(PATH + '/bus.txt', 'w')
-        f.write(arrow.get(ts).humanize())
+        f.write(' and '.join(times))
         f.close()
 
         time.sleep(30)