gjohansson-ST / pytrafikverket

python module for communicating with the swedish trafikverket api
MIT License
22 stars 7 forks source link

Can't handle some duplicate station names #8

Closed MuMu21 closed 3 years ago

MuMu21 commented 3 years ago

For example Marma. Searching gives three different results, which of two are the same but different station signature. I have no direct solution for this, other than the possibility to use station signature instead.

$ python3 pytrafikverket.py -key xxx -method search-for-station -station "Marma" Marma Maa Marma Mrm Marmaverken Me

$ python3 pytrafikverket.py -key xxx -method get-next-train-stop -from-station "Marma" -to-station "Uppsala C" Traceback (most recent call last): File "pytrafikverket.py", line 4, in main.main() File "/home/petter/python/pytrafikverket/main.py", line 153, in main loop.run_until_complete(async_main(loop)) File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "/home/petter/python/pytrafikverket/main.py", line 79, in async_main from_station = await train_api.async_get_train_station( File "/home/petter/python/pytrafikverket/trafikverket_train.py", line 132, in async_get_train_station raise ValueError( ValueError: Found multiple stations with the specified name

endor-force commented 3 years ago

I have added filter in the station search to only search for advertised stations which should only return stations that are advertised in a timetable when looking up.

Advertised | boolean | Anger om stationen annonseras i tidtabell

I have not updated pip package yet, could you verify with the latest git version if it works ok?

MuMu21 commented 3 years ago

Lovely! This did the trick.