fedebotu / k-trains

An app for automatically reserving trains in Korea - both Korail and SRT - even when sold out
https://k-trains.streamlit.app
47 stars 29 forks source link

How to fix SRT.session.error ?? #23

Open daje0601 opened 2 weeks ago

daje0601 commented 2 weeks ago
Notification mail sent successfully.
Error:
Traceback (most recent call last):
  File "/Users/.../Documents/k-trains/reserve.py", line 93, in get_trains
    trains = ktrains.search_train(dep, arr, date, time, available_only=False)
  File "/Users/.../Documents/k-trains/ktrains/srt/srt.py", line 231, in search_train
    raise SRTResponseError(parser.message())
ktrains.srt.errors.SRTResponseError: 사용자가 많아 접속이 원활하지 않습니다.<br>잠시 후 다시 이용하여 주시기바랍니다.

Error occurred
Sending error message
Notification mail sent successfully.

I've only been running for about 5 minutes and I got this error. I'm not sure if I can leave it alone or if I need to run it again, what should I do?

Also, I don't want these errors to occur, so where should I fix them?

daje0601 commented 2 weeks ago
Running main script!
Sending start message
Notification mail sent successfully.
Error:
Traceback (most recent call last):
  File "/Users/gangdasol/Documents/k-trains/reserve.py", line 93, in get_trains
    trains = ktrains.search_train(dep, arr, date, time, available_only=False)
  File "/Users/gangdasol/Documents/k-trains/ktrains/srt/srt.py", line 228, in search_train
    parser = SRTResponseData(r.text)
  File "/Users/.../Documents/k-trains/ktrains/srt/response_data.py", line 19, in __init__
    self._parse()
  File "/Users/.../Documents/k-trains/ktrains/srt/response_data.py", line 28, in _parse
    self._status = self._json["resultMap"][0]
KeyError: 'resultMap'

Error occurred
Sending error message
Notification mail sent successfully.

The problem is probably in the process of successfully making the booking, getting the data from the API, and parsing it. Is it because the API specification is different? or Should I be checking other things?. I did a customisation to add the recently added SRT station.

fedebotu commented 2 weeks ago

Hi @daje0601 ! Thanks for reporting. The first message is probably due to the bot making too many requests (recently Korail + SRT updated their systems), so I guess we should update this part so that the block is not triggered.

About the second: my guess is that we should update the code to use the update SRT API code: https://github.com/ryanking13/SRT