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",
"trilex WiFi",
"DBLounge",
"48WEc-024 5GHz",
"Pendolino_WiFi",
]
@ -76,11 +78,16 @@ def get_api_cd():
"http://cdwifi.cz/portal/api/vehicle/realtime", timeout=5
)
statusDataCD = statusDataCD_response.json()
tripDataCD_response = requests.get(
"http://cdwifi.cz/portal/api/timetable/connexion/current", timeout=5
)
tripDataCD = tripDataCD_response.json()
return 1
except requests.exceptions.RequestException:
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)
def get_ssid():
try:
@ -147,39 +154,44 @@ def get_next_db():
def get_next_tl():
try:
if len(tripDataTl["intermediateStops"])==0:
if len(tripDataTl["intermediateStops"]) == 0:
tripinfo = tripDataTl["toStation"]["name"]
else:
for i in tripDataTl["intermediateStops"]:
if i["realArrival"] == None:
nextStopArrival=i["scheduledArrival"]
else:
nextStopArrival=i["realArrival"]
nextStopArrival = i["realArrival"] or i["scheduledArrival"]
if nextStopArrival is None:
continue
if nextStopArrival >= time.time():
nextStationName = i["name"]
uScheduledTime = i["scheduledArrival"]
uActualTime = i["realArrival"]
if uActualTime == None:
arrivalDelay="-"
arrivalDelay = "-"
else:
arrivalDelay = "{:+.0f}".format(((uActualTime - uScheduledTime) / 60))
arrivalTime = datetime.fromtimestamp(nextStopArrival, tz=timezone).strftime(
"%H:%M"
arrivalDelay = "{:+.0f}".format(
((uActualTime - uScheduledTime) / 60)
)
arrivalTime = datetime.fromtimestamp(
nextStopArrival, tz=timezone
).strftime("%H:%M")
tripinfo = (
nextStationName + " " + arrivalTime + " (" + arrivalDelay + ")"
)
break
else:
next
tripinfo = tripDataTl["toStation"]["name"]
except:
tripinfo = tripDataTl["toStation"]["name"]
return tripinfo
def get_next_cd():
tripinfo = ""
return tripinfo
# Get the Trainnumber and final station of your current train
def get_trainInfo_db():
if tripData["trip"]["trainType"] == None:
@ -190,21 +202,24 @@ def get_trainInfo_db():
finalStationName = tripData["trip"]["stopInfo"]["finalStationName"] or ""
return trainType + " " + trainNumber
# Get the Trainnumber and final station of your current travelynx trip
def get_trainInfo_tl():
checkin_tl()
trainType = tripDataTl["train"]["type"] or ""
trainNumber = tripDataTl["train"]["no"] or ""
#fromStationName = tripDataTl["fromStation"]["name"]
fromStationDS100=tripDataTl['fromStation']['ds100'] or ""
toStationDS100=tripDataTl['toStation']['ds100'] or ""
# fromStationName = tripDataTl["fromStation"]["name"]
fromStationDS100 = tripDataTl["fromStation"]["ds100"] or ""
toStationDS100 = tripDataTl["toStation"]["ds100"] or ""
toStationName = tripDataTl["toStation"]["name"] or ""
toStationTrack = tripDataTl["toStation"]["platform"] or ""
uScheduledTime = tripDataTl["toStation"]["scheduledTime"] or ""
uActualTime = tripDataTl["toStation"]["realTime"] or ""
arrivalDelay = "{:+.0f}".format(((uActualTime - uScheduledTime) / 60)) or ""
arrivalTime = datetime.fromtimestamp(uActualTime, tz=timezone).strftime("%H:%M") or ""
nextStop=get_next_tl()
arrivalTime = (
datetime.fromtimestamp(uActualTime, tz=timezone).strftime("%H:%M") or ""
)
nextStop = get_next_tl()
return (
trainType
+ " "
@ -222,7 +237,6 @@ def get_trainInfo_tl():
)
def checkin_tl():
if tripDataTl["checkedIn"] == False:
sys.exit()
@ -260,11 +274,7 @@ def main():
re.sub(
r"\s+",
" ",
get_trainInfo_tl()
+ " | "
+ "SPEED: "
+ get_speed_cd()
+ " km/h"
get_trainInfo_tl() + " | " + "SPEED: " + get_speed_cd() + " km/h",
)
)