Python package for interacting & fetching somtoday's data.
Project description
Somtoday Python, the interactor
changes in 0.0.4
- I got more lazier so I wanted to announce this in Dutch
- Gefixt dat Student.fetch_schedule(group_by_day=True) dat het weer werkt(zat blijkbaar een bug in)
- Documentatie verbetert
- Er zat een probleem met Union types, gefixt
- Je kan 2 studenten vergelijken als Student.full_name en Student.school_name allebei gelijk zijn
- Vergelijkingen met Cijfers(kijken als cijfers zijn hoger of lager) Cijfers worden bepaald door Cijfers.resultaat
- beter __repr__ en __str__ voor Cijfer en Subject
- Cijfers resultaat yielden is mogelijk door Student.yield_fetch_cijfers() te doen (ook met asynchronous)
- Rooster vakken yielden is mogelijk door Student.yield_fetch_schedule() te doen (ook met asynchronous)
somtodaypython is a package that fetches and interacts with Somtoday API using https requests.
installation
for macos & linux
python3 -m pip3 install somtodaypython
for windows
python3 -m pip install somtodaypython
OR
python -m pip install somtodaypython
if neither above works then you can always do this
pip3 install git+https://github.com/luxkatana/somtodayapi_python
If you want to try beta versions do this
pip3 install git+https://github.com/luxkatana/somtodayapi_python/dev
examples
basic interacting with a student(getting data from the student)
import somtodaypython.nonasyncsomtoday as nonasync_somtoday
school = nonasync_somtoday.find_school("SchoolName")
student = school.get_student("NAME", "password")
print(f"email : {student.email}\tname: {student.full_name}\tgender: {student.gender}")
basic interacting with the timetable of a student
import somtodaypython.nonasyncsomtoday as nonasync_somtoday
from datetime import timedelta, datetime as dt
school = nonasync_somtoday.find_school("SchoolName")
student = school.get_student("NAME", "password")
today = dt.now()
tomorrow = today + timedelta(days=2)
timetable: list[list[nonasync_somtoday.Subject]] = student.fetch_schedule(today, tomorrow, group_by_day=True)
for day in timetable:
for day_subject in day:
print(day_subject.subject_name)
Asynchronous support
We also support asynchronous for somtodaypython.
Basic interacting with a student(asynchronous)
import somtodaypython.asynchronous_somtoday as async_somtoday
import asyncio # builtin library for asynchronous execution
async def main() -> None:
school = await async_somtoday.find_school("SCHOOLNAME")
student = await school.get_student("NAME", "PASSWORD")
print(student.full_name)
asyncio.get_event_loop().run_until_complete(main()) # executing the main() function
Basic interacting with a student's timetable(asynchronous)
import somtodaypython.asynchronous_somtoday as async_somtoday
from datetime import timedelta,datetime as dt
import asyncio # builtin library for asynchronous execution
async def main() -> None:
now = dt.now()
tomorrow = now + timedelta(days=2)
school = await async_somtoday.find_school("SCHOOLNAME")
student = await school.get_student("NAME", "PASSWORD")
timetable: list[list[async_somtoday.Subject]] = await student.fetch_schedule(now, tomorrow, group_by_day=True)
for day in timetable:
for subject in day:
print(subject.subject_name)
asyncio.get_event_loop().run_until_complete(main()) # executing the main() function
Ending
New features are always welcome! email taseen.bibi@gmail.com
Huizengek#6623 Special thanks to Huizengek#6623 for showing the method of getting the access token & interacting with the somtoday API.
github: https://github.com/25huizengek1
elisaado
Special thanks to elisaado for making important API endpoints visible to other users.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for somtodaypython-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9140fb80cf415e9588f999ee0289a6ddf4365cbb2f38f47474cc23941fe4d0b8 |
|
MD5 | a0246cf7bcc9e7165f6e691ea7fac945 |
|
BLAKE2b-256 | b08d5687c9fa74aceef88968e9e212c3d4ee4acee817ae4b3dba3d52b794ecb9 |