aktualisiert
This commit is contained in:
parent
66255627e5
commit
8fc4b57380
|
|
@ -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:
|
||||
|
|
@ -151,11 +158,9 @@ def get_next_tl():
|
|||
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"]
|
||||
|
|
@ -163,23 +168,30 @@ def get_next_tl():
|
|||
if uActualTime == None:
|
||||
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,20 +202,23 @@ 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 ""
|
||||
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 ""
|
||||
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",
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue