fix datasource for tripinfo

This commit is contained in:
chrissy 2025-10-26 13:49:02 +01:00
parent 5284f9a781
commit 9b97384b69
1 changed files with 3 additions and 3 deletions

View File

@ -30,8 +30,8 @@ def get_speed_db():
def get_trip_db(): def get_trip_db():
rs = "https://iceportal.de/api1/rs/tripInfo/trip/" rs = "https://iceportal.de/api1/rs/tripInfo/trip/"
database = "trip.json" response = get(rs)
data = json.loads(open(database).read()) data = response.json()
next_stop=data["trip"]["stopInfo"]["actualNext"] next_stop=data["trip"]["stopInfo"]["actualNext"]
for i in data['trip']['stops']: for i in data['trip']['stops']:
@ -41,7 +41,7 @@ def get_trip_db():
utime=i['timetable']['actualArrivalTime']/1000 utime=i['timetable']['actualArrivalTime']/1000
arrivalTime = datetime.fromtimestamp(utime, tz=timezonedt).strftime('%H:%M') arrivalTime = datetime.fromtimestamp(utime, tz=timezonedt).strftime('%H:%M')
break break
tripinfo = nextStationName + arrivalTime + arrivalDelay tripinfo = nextStationName+" "+ arrivalTime+" " + arrivalDelay
return tripinfo return tripinfo
def main(): def main():