mvg
mvg copied to clipboard
Feature proposals: helper utilities
Hi,
Great project. i was building something similar for an rpi project, then found this amazing API, saved a lot of work! Surprisingly, MvgApi.stations() returns 43,927 stations (not just Munich, but all of Bavaria!)!
The API is already solid. I have a few ideas that might make it more beginner-friendly and some quality-of-life functionality:
1. String transport types
# Current
departures(transport_types=[TransportType.UBAHN, TransportType.SBAHN])
# Proposed (also accept strings)
departures(transport_types=["U-bahn", TransportType.SBAHN]) # also work with "ubahn"
2. Return multiple station matches
# station() returns first match - add option to get first N?
stations = MvgApi.stations_search("flughafen", limit=5)
# Returns: [Flughafen Besucherpark , Flughafen Nürnberg, Flughafen München... ]
3. Departure sorting
departures(sort_by="time") # or "line", "type" etc
4. Print helper
MvgApi.print_departures(departures)
Line Destination Planned Live Status
---------------------------------------------------------------
U3 Fuerstenried West 14:32 14:32 [OK]
U6 Klinikum Grosshadern 14:33 14:36 [DELAY +3m]
S1 Freising 14:35 14:35 [OK]
5. Multi-station query
departures_multi(["Marienplatz", "Hauptbahnhof"], sort_by="station", limit_per_station=2)
# or extending the existing departures to accept a list of stations
6. DataFrame export (optional pandas dep)
df = MvgApi.to_dataframe(departures)
Happy to submit PRs if you're interested. Would you prefer small separate PRs or grouped by theme?