Skip to content
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

v0.0.6 | Offset Fix #13

Merged
merged 4 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ async def main():
api = BonchAPI()
await api.login("YourMail", "YourPassword")
await api.click_start_lesson() # автокликалка на парах
await api.get_timetable() # красивая моделька расписания

asyncio.run(main())
```

---

[BonchCLI](https://github.com/KarimullinArthur/BonchCLI) - клиент lk.sut.ru для красноглазиков
19 changes: 18 additions & 1 deletion bonchapi/bonchapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,28 @@ async def get_raw_timetable(self, week_number: int = False) -> str:
await self.login(self.mail, self.password)
await self.get_raw_timetable(week_number)
return await resp.text()

async def find_first_week_id(self) -> int:
'''
Получение ID первой учебной недели в *семестре*
'''
MAX_WEEK = 50

for i in (0,-1,-2,1,2):
id = MAX_WEEK//2+i
guess = await parser.get_week(await self.get_raw_timetable(id))
if guess == 0:
return id
return 0

async def get_timetable(self, week_number: int = False, *, week_offset: int = False) -> List[schemas.Lesson]:
if week_offset:

if not hasattr(self, "_first_week"):
self._first_week = await self.find_first_week_id()

current_week = await parser.get_week(await self.get_raw_timetable(week_number))
desired_week = current_week + week_offset
desired_week = current_week + week_offset + self._first_week
return await parser.get_my_lessons(await self.get_raw_timetable(desired_week))

else:
Expand Down
192 changes: 0 additions & 192 deletions index.html

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "bonchapi"
version = "0.0.5"
version = "0.0.6"
description = 'API client for lk.sut.ru'
readme = "README.md"
requires-python = ">=3.8"
Expand Down