aktualisiert
This commit is contained in:
parent
66255627e5
commit
8fc4b57380
|
|
@ -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:
|
||||||
|
|
@ -147,39 +154,44 @@ def get_next_db():
|
||||||
|
|
||||||
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:
|
||||||
|
|
@ -190,21 +202,24 @@ def get_trainInfo_db():
|
||||||
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,11 +274,7 @@ 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"
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue