aktualisiert

This commit is contained in:
Luzia Christiane Tesar 2026-09-11 10:09:23 +02:00
parent 66255627e5
commit 8fc4b57380
1 changed files with 42 additions and 32 deletions

View File

@ -38,6 +38,8 @@ ssid_regio = [
"alex WiFi", "alex WiFi",
"trilex WiFi", "trilex WiFi",
"DBLounge", "DBLounge",
"48WEc-024 5GHz",
"Pendolino_WiFi",
] ]
@ -76,11 +78,16 @@ def get_api_cd():
"http://cdwifi.cz/portal/api/vehicle/realtime", timeout=5 "http://cdwifi.cz/portal/api/vehicle/realtime", timeout=5
) )
statusDataCD = statusDataCD_response.json() statusDataCD = statusDataCD_response.json()
tripDataCD_response = requests.get(
"http://cdwifi.cz/portal/api/timetable/connexion/current", timeout=5
)
tripDataCD = tripDataCD_response.json()
return 1 return 1
except requests.exceptions.RequestException: except requests.exceptions.RequestException:
return 0 return 0
# Look for the current SSID. Replace wlp2s0 with the real name of your wifi interface and check, that the path to iwlist is correct (just type 'which iwlist' in the terminal) # Look for the current SSID. Replace wlp2s0 with the real name of your wifi interface and check, that the path to iwlist is correct (just type 'which iwlist' in the terminal)
def get_ssid(): def get_ssid():
try: try:
@ -115,7 +122,7 @@ def get_speed_cd():
# Figure out, whats the next station and filter the output for this. # Figure out, whats the next station and filter the output for this.
def get_next_db(): def get_next_db():
try: try:
if tripData["trip"]["stopInfo"] == None: if tripData["trip"]["stopInfo"] == None:
return "No TripInfo" return "No TripInfo"
@ -140,46 +147,51 @@ def get_next_db():
+ ") @ " + ") @ "
+ nextStationTrack + nextStationTrack
) )
except: except:
tripinfo = "Unavail" tripinfo = "Unavail"
return tripinfo return tripinfo
def get_next_tl(): def get_next_tl():
try: try:
if len(tripDataTl["intermediateStops"])==0: if len(tripDataTl["intermediateStops"]) == 0:
tripinfo = tripDataTl["toStation"]["name"] tripinfo = tripDataTl["toStation"]["name"]
else: else:
for i in tripDataTl["intermediateStops"]: for i in tripDataTl["intermediateStops"]:
if i["realArrival"] == None: nextStopArrival = i["realArrival"] or i["scheduledArrival"]
nextStopArrival=i["scheduledArrival"] if nextStopArrival is None:
else: continue
nextStopArrival=i["realArrival"]
if nextStopArrival >= time.time(): if nextStopArrival >= time.time():
nextStationName = i["name"] nextStationName = i["name"]
uScheduledTime = i["scheduledArrival"] uScheduledTime = i["scheduledArrival"]
uActualTime = i["realArrival"] uActualTime = i["realArrival"]
if uActualTime == None: if uActualTime == None:
arrivalDelay="-" arrivalDelay = "-"
else: else:
arrivalDelay = "{:+.0f}".format(((uActualTime - uScheduledTime) / 60)) arrivalDelay = "{:+.0f}".format(
((uActualTime - uScheduledTime) / 60)
arrivalTime = datetime.fromtimestamp(nextStopArrival, tz=timezone).strftime( )
"%H:%M"
) arrivalTime = datetime.fromtimestamp(
nextStopArrival, tz=timezone
).strftime("%H:%M")
tripinfo = ( tripinfo = (
nextStationName + " " + arrivalTime + " (" + arrivalDelay + ")" nextStationName + " " + arrivalTime + " (" + arrivalDelay + ")"
) )
break break
else: else:
next tripinfo = tripDataTl["toStation"]["name"]
tripinfo = tripDataTl["toStation"]["name"]
except: except:
tripinfo = tripDataTl["toStation"]["name"] tripinfo = tripDataTl["toStation"]["name"]
return tripinfo return tripinfo
def get_next_cd():
tripinfo = ""
return tripinfo
# Get the Trainnumber and final station of your current train # Get the Trainnumber and final station of your current train
def get_trainInfo_db(): def get_trainInfo_db():
if tripData["trip"]["trainType"] == None: if tripData["trip"]["trainType"] == None:
@ -188,23 +200,26 @@ def get_trainInfo_db():
trainType = tripData["trip"]["trainType"] or "" trainType = tripData["trip"]["trainType"] or ""
trainNumber = tripData["trip"]["vzn"] or "" trainNumber = tripData["trip"]["vzn"] or ""
finalStationName = tripData["trip"]["stopInfo"]["finalStationName"] or "" finalStationName = tripData["trip"]["stopInfo"]["finalStationName"] or ""
return trainType + " " + trainNumber return trainType + " " + trainNumber
# Get the Trainnumber and final station of your current travelynx trip # Get the Trainnumber and final station of your current travelynx trip
def get_trainInfo_tl(): def get_trainInfo_tl():
checkin_tl() checkin_tl()
trainType = tripDataTl["train"]["type"] or "" trainType = tripDataTl["train"]["type"] or ""
trainNumber = tripDataTl["train"]["no"] or "" trainNumber = tripDataTl["train"]["no"] or ""
#fromStationName = tripDataTl["fromStation"]["name"] # fromStationName = tripDataTl["fromStation"]["name"]
fromStationDS100=tripDataTl['fromStation']['ds100'] or "" fromStationDS100 = tripDataTl["fromStation"]["ds100"] or ""
toStationDS100=tripDataTl['toStation']['ds100'] or "" toStationDS100 = tripDataTl["toStation"]["ds100"] or ""
toStationName = tripDataTl["toStation"]["name"] or "" toStationName = tripDataTl["toStation"]["name"] or ""
toStationTrack = tripDataTl["toStation"]["platform"] or "" toStationTrack = tripDataTl["toStation"]["platform"] or ""
uScheduledTime = tripDataTl["toStation"]["scheduledTime"] or "" uScheduledTime = tripDataTl["toStation"]["scheduledTime"] or ""
uActualTime = tripDataTl["toStation"]["realTime"] or "" uActualTime = tripDataTl["toStation"]["realTime"] or ""
arrivalDelay = "{:+.0f}".format(((uActualTime - uScheduledTime) / 60)) or "" arrivalDelay = "{:+.0f}".format(((uActualTime - uScheduledTime) / 60)) or ""
arrivalTime = datetime.fromtimestamp(uActualTime, tz=timezone).strftime("%H:%M") or "" arrivalTime = (
nextStop=get_next_tl() datetime.fromtimestamp(uActualTime, tz=timezone).strftime("%H:%M") or ""
)
nextStop = get_next_tl()
return ( return (
trainType trainType
+ " " + " "
@ -222,7 +237,6 @@ def get_trainInfo_tl():
) )
def checkin_tl(): def checkin_tl():
if tripDataTl["checkedIn"] == False: if tripDataTl["checkedIn"] == False:
sys.exit() sys.exit()
@ -260,12 +274,8 @@ def main():
re.sub( re.sub(
r"\s+", r"\s+",
" ", " ",
get_trainInfo_tl() get_trainInfo_tl() + " | " + "SPEED: " + get_speed_cd() + " km/h",
+ " | " )
+ "SPEED: "
+ get_speed_cd()
+ " km/h"
)
) )