Skip to main content

Ассинхронная Python-библиотека с легким доступом к сервису МЭШ, написанная на aiohttp и async_playwright

Project description

aiomes

AIOMES - ассинхронная Python-библиотека, написанная на aiohttp и async_playwright, с легким доступом к сервису МЭШ

Примечание:

Библиотека может работать только с профилем ученика.

Установка:

pip install aiomes
playwright install firefox

Оглавление методов библиотеки:

Методы:

Авторизация по логину и паролю

from playwright.async_api import async_playwright
import asyncio
import aiomes

LOGIN = ...
PASSWORD = ...

async def main():
    async with async_playwright() as p:
        auth = await aiomes.AUTH(p)
        token = await auth.obtain_token(LOGIN, PASSWORD)

        if token == '2FA_NEEDED':
            sms_code = str(input())  # Реализация вашей логики получения 2FA-кода
            token = await auth.proceed_2fa(sms_code)

    user = await aiomes.Client(token)

asyncio.run(main())

Авторизация по токену

import asyncio
import aiomes

TOKEN = ...

async def main():
  user = await aiomes.Client(TOKEN)

asyncio.run(main())

Получение расписания

schedule = await user.get_schedule()

for subject in schedule:
    print(f"{subject.name}, {subject.start_time} - {subject.end_time}, к. {subject.room_number}; {subject.marks}")

Получение короткого расписания

today = date.today()
short_schedule = await user.get_schedule_short([today, today+timedelta(1), ...])
    
for subject in short_schedule:
    print(f"{subject.name}, {subject.start_time} - {subject.end_time}")

Получение расписания каникул

periods_schedule = await user.get_periods_schedule()

for subject in periods_schedule:
    print(f"{period.name}: {period.starts}{period.ends}")

Получение домашнего задания

homework = await user.get_homeworks(from_date=date.today(), to_date=date.today())

for hw in homework:
    print(hw.hw_date.strftime('%d/%m'))
    print(f"{hw.subject_name}: {hw.description}; {hw.attached_files}, {hw.attached_tests}")
    print("-"*15)

Получение оценок

marks = await user.get_marks(from_date=date.today()-timedelta(7), to_date=date.today())

for mark in sorted(marks, key=lambda x: x.mark_date):
    print(f"{mark.subject_name}: {mark.value} [{mark.weight}] - {mark.reason}")

Получение оценок за период

period_marks = await user.get_period_marks(year_id=user.class_level, period_id=0)  # [Текущий класс, первый период]

for per_mark in period_marks:
    print(f"{per_mark.subject_name} - {per_mark.average_mark}, {per_mark.final_mark}; {per_mark.marks}")

Получение итог. оценок за прошлые года

past_marks = await user.get_past_final_marks(class_number=9)  # [Номер класса]

for past_mark in past_marks:
    print(f"{past_mark.subject_name} - {past_mark.final_mark}")

Получение информации о школе

school = await user.get_school_info()

print(school.name, school.address)
print(school.site, school.email)
print(school.principal)

Получение меню школьной столовой

today = date.today()
menu = await user.get_menu(today)

for item in menu:
    print(f'{item.title}{item.price}:')
    for meal in item.composition:
        print(f'- {meal.name}, {meal.ingredients}, {meal.calories}')
    print('-'*35)

Получение меню школьного буфета

today = date.today()
buffet_menu = await user.get_menu_buffet(today)

for item in buffet_menu:
    print(item.name, item.full_name, item.price, item.is_available)

Получение посещаемости

today = date.today()
attendance = await user.get_visits(from_date=today - timedelta(7), to_date=today)

for day in attendance:
    print(f"{day.visit_date}: {day.in_time}-{day.out_time}, {day.duration}")

Получение всех уведомлений

notifications = await user.get_notifications()

for n in notifications:
    n_date = datetime.strftime(n.event_date, '%d/%m')
    print(f'{n_date}, {n.event_name} [{n.mark_value}], [{n.hw_description}]')

Получение рейтинга в классе

today = date.today()
ranking = await user.get_class_rank(date_from=today - timedelta(7), date_to=today)

for day in ranking:
    print(f"{day.rank_date}, {day.place}")

Получение документов ученика

docs = await user.get_docs()

for doc in docs:
    print(f"{doc.type_id} / {doc.series}, {doc.number} / {doc.issuer}, {doc.issue_date}")

Получение списка предметов

subjects = await user.get_subjects()

print(", ".join(subjects))

[ Asyncronous Input Output Moscow Electronic School ]

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

aiomes-1.5.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

aiomes-1.5.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file aiomes-1.5.2.tar.gz.

File metadata

  • Download URL: aiomes-1.5.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for aiomes-1.5.2.tar.gz
Algorithm Hash digest
SHA256 99f51d223bd676a147c4dad85593c185e99cb56b25020772a6ecaef832e01d87
MD5 d722c92777bc2d5f6a5a5fabb0ee51ac
BLAKE2b-256 7366582f7f35e4aa48d18437d98a5a8d99c572d04ff877717f7fd16b2003bc03

See more details on using hashes here.

File details

Details for the file aiomes-1.5.2-py3-none-any.whl.

File metadata

  • Download URL: aiomes-1.5.2-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for aiomes-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c60d90b8b4454fc59366217a9f49f0a76ab9badb7234fb910b7eee5cb271e87c
MD5 d8f1ce891c4a62c498f3b4d80092a3b9
BLAKE2b-256 a48b1132a5cffebaffc086fbb5ef6ebb5457457113659796c4a6a006046bc2c5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page