-
Notifications
You must be signed in to change notification settings - Fork 15
Add support for attendance #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Just tested both example codes but I'm getting exception in JSON response parsing.
It lookls like the json data was incorrectly parsed from the html response. Obviously I'm getting different html response that you, but I don't know why. |
|
@kapitan-iglu Does Maybe your id (returned by Uninstall the current version: pip uninstall edupage-apiYou can install the version of edupage_api from this branch pip install -U git+https://github.com/EdupageAPI/edupage-api@feature/attendanceAnd to revert back: |
Yes, my user ID contains hyphen, so removing it is good idea. But...
First suggestion is to use Example code: --- attendance.py
+++ attendance_edited.py
@@ -60,21 +60,21 @@
response = self.edupage.session.get(request_url, params=params)
response_html = response.text
- user_id_number = Attendance.__get_user_id_number(user_id)
try:
data = response_html.split(
'ASC.requireAsync("/dashboard/dochadzka.js#initZiak").then'
- )[1][37:].split(f",[{user_id_number}],true);")[0]
+ )[1][37:].split("],true);});")[0]
+ data = data[0:data.rindex(",[")]
return json.loads(data)
- except IndexError:
+ except (IndexError, ValueError):
raise MissingDataException(
'Unexpected response from attendance endpoint! (expected string `ASC.requireAsync("/dashboard/dochadzka.js#initZiak").then` to be in the response)'
)
@staticmethod
def __get_user_id_number(user_id: str):
- return user_id.replace("Student", "").replace("Ucitel", "").replace("-", "")
+ return user_id.replace("Student", "").replace("Ucitel", "").replace("Rodic", "").replace("-", "")
def get_days_with_available_attendance(self, user_id: str) -> list[date]:
user_id_number = Attendance.__get_user_id_number(With this code I was able to get valid JSON data from So, I suppose that Any ideas? Second suggestion is to catch also |
Hopefully fixes #97.
Currently there is support for "statistics" (how many late/excused/unexcused/absent lessons?) and arrivals (the time of arrival and departure from school).
Example usage
Here is a short example, that prints how many missed lessons there are for each day where there is attendance data, and checks if all the missed lessons are excused:
And for the last new method, here is a short example that prints the arrival and departure time for each date where there is attendance data:
@kapitan-iglu, could you please test if this solves your issue? While developing I noticed that only days with an excuse note show up in the
My Attendance->Arrivals to schoolcolumn. Maybe I am looking at the wrong page? Is that the case for you?You can install the version of
edupage_apifrom this branch by running:And to revert back: