mirror of
https://github.com/kaaninchen/Gleiswechsel.git
synced 2026-07-21 19:52:47 +00:00
Operator-logik effizienter gemacht
Durch die neuen Infos ist es möglich, die Betreiber direkt auszulesen. Dadurch muss nicht nur ein Betreiber komisch durch die Anfangsbuchstaben gefunden werden
This commit is contained in:
+9
-9
@@ -18,7 +18,8 @@ def random_connection():
|
||||
|
||||
departures = [
|
||||
d for d in data.get("departures", [])
|
||||
if d.get("scheduledDeparture") and d.get("destination") != station
|
||||
if d.get("scheduledDeparture") and d.get("destination") != station
|
||||
and not d.get("train", "").startswith("S ")
|
||||
]
|
||||
|
||||
if not departures:
|
||||
@@ -34,14 +35,6 @@ def random_connection():
|
||||
"station": station,
|
||||
"train_number": dep['trainNumber']
|
||||
}
|
||||
|
||||
|
||||
def operator_infos(train):
|
||||
if not train:
|
||||
return OPERATORS["fallback"]
|
||||
|
||||
train_type = train.split()[0]
|
||||
return OPERATORS.get(train_type, OPERATORS["fallback"])
|
||||
|
||||
def format_via_list(via: list[str]):
|
||||
if not via:
|
||||
@@ -61,11 +54,18 @@ def get_train_info(station, train_ID, train_type):
|
||||
|
||||
dep = data.get("departure", [])
|
||||
arrival_iso = dep["route_post_diff"][-1]["sched_arr"]
|
||||
print(dep["operators"])
|
||||
return {
|
||||
"arrival": arrival_iso,
|
||||
"operators": dep["operators"]
|
||||
}
|
||||
|
||||
def operator_metadata(operator):
|
||||
if not operator:
|
||||
return OPERATORS["fallback"]
|
||||
|
||||
return OPERATORS.get(operator, OPERATORS["fallback"])
|
||||
|
||||
def logger(msg):
|
||||
current_time = datetime.now().strftime('%X')
|
||||
print(f"{current_time}: {msg}")
|
||||
Reference in New Issue
Block a user