EdupageAPI / edupage-api

A python library for accessing your Edupage account
https://edupageapi.github.io/edupage-api/
GNU General Public License v3.0
67 stars 13 forks source link

Timetable not working #12

Closed DominikDolezel closed 3 years ago

DominikDolezel commented 3 years ago

Hello, so I have this code:

from edupage_api import Edupage, EduTime, EduDate, BadCredentialsException, LoginDataParsingException

edupage = Edupage("#####", "#####", "#####")
try:
    edupage.login()
except BadCredentialsException:
    print("Wrong username or password!")
except LoginDataParsingException:
    print("Try again or open an issue!")

today = EduDate.today() 

timetable = edupage.get_timetable(today) 

first_lesson = timetable.get_first_lesson()

start_time = first_lesson.start

print(start_time)

but it gives me an error:

Subject ID when fetching data:
Traceback (most recent call last):
  File "lesson_updater.py", line 26, in <module>
    timetable = edupage.get_timetable(today) 
  File "/home/dominik/.local/lib/python3.8/site-packages/edupage_api/__init__.py", line 97, in get_timetable
    subject_name = self.ids.id_to_subject(subject_id)
  File "/home/dominik/.local/lib/python3.8/site-packages/edupage_api/utils.py", line 63, in id_to_subject
    return self.dbi.get("subjects").get(s_id).get("short")
AttributeError: 'NoneType' object has no attribute 'get'

I am sure it isn't a problem with login, since that would print login error, but it doesn't. Thanks in advance.

ivanhrabcak commented 3 years ago

Hello, I can reproduce this issue and I am working on a fix

BelKed commented 3 years ago

I think, it is now fixed in fb873a7. Anyway, syntax for getting start of lesson had slightly changed:

start_time = first_lesson.length.start
ivanhrabcak commented 3 years ago

Yes, fixed!