mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-09 12:08:47 +00:00
Merge branch 'patch-1' into 'main'
Draft: Automatische Aktualisierung der Abfahrtszeiten hinzugefügt See merge request oeffi/oeffi!21
This commit is contained in:
commit
62d2e0e465
2 changed files with 27 additions and 1 deletions
|
@ -31,3 +31,4 @@ bookworm-jdk17:
|
||||||
name: oeffi-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
|
name: oeffi-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
|
||||||
paths:
|
paths:
|
||||||
- oeffi/build/outputs/apk/**/*.apk
|
- oeffi/build/outputs/apk/**/*.apk
|
||||||
|
pytest
|
|
@ -1,4 +1,29 @@
|
||||||
v13.0.4-v13.0.10
|
import requests import time from datetime import datetime
|
||||||
|
|
||||||
|
API-Endpunkt für Abfahrtszeiten (Beispiel-URL)
|
||||||
|
|
||||||
|
API_URL = "https://api.deinverkehrsverbund.de/abfahrtszeiten"
|
||||||
|
|
||||||
|
Funktion, um Abfahrtszeiten zu erhalten
|
||||||
|
|
||||||
|
def get_abfahrtszeiten(station_id): try: response = requests.get(f"{API_URL}/{station_id}") response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: print(f"Fehler beim Abruf: {e}") return []
|
||||||
|
|
||||||
|
Automatische Aktualisierung der Abfahrtszeiten
|
||||||
|
|
||||||
|
def update_abfahrtszeiten(station_id, interval=10): while True: print(f"Aktualisiere Station {station_id}...") abfahrten = get_abfahrtszeiten(station_id)
|
||||||
|
|
||||||
|
if abfahrten:
|
||||||
|
print(f"Neue Zeiten: {abfahrten}")
|
||||||
|
else:
|
||||||
|
print("Keine Abfahrtszeiten verfügbar.")
|
||||||
|
|
||||||
|
time.sleep(interval * 60)
|
||||||
|
|
||||||
|
Beispielstation und Start des Skripts
|
||||||
|
|
||||||
|
station_id = "obstwiesen_id" update_abfahrtszeiten(station_id, interval=10)
|
||||||
|
|
||||||
|
v13.0.4-v13.0.10
|
||||||
|
|
||||||
* Target Android 15.
|
* Target Android 15.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue