Edupage.org timetable parser library
Project description
Edupage.org timetable parser library
This library provides access to public timetables provided by Edupage. The resulting dataset is compatible with and based on timetables-lib.
Usage examples
Simple login
async with EdupageApi() as api:
# login with Edupage Portal (account for multiple schools)
portal: Portal = await api.login(login="email@example.com", password="PortalPassword")
# OR
# login with a single-school Edupage account (i.e. https://example.edupage.com)
session: Session = await api.login(login="user12345", password="EdupageUser123", edupage="example")
# OR
# login using a previously stored session (Portal login not possible here)
session: Session = await api.login(**old_session.dict())
# list sessions joined to a Portal account
print(portal.sessions)
# get the first session (school)
session = portal.sessions[0]
Note: it is recommended to save sessions (portal.dict() or session.dict()) for future API calls.
The sessions expire after some (unknown to me) time, a SessionExpiredError
is raised in that case.
Parse timetables
async with EdupageParser(session) as parser:
# enqueue parsing all data (this is required)
# - try_v1_teachers - whether to use the old API to get some teachers' full names
# - try_v1_full_teachers - whether to use the old API to get all teachers' full names
# ^ this option requires to download and extract a large, zipped JSON payload, so keep this in mind
parser.enqueue_all(try_v1_teachers=False, try_v1_full_teachers=True)
# print the current queue, out of curiosity
print("\n".join(str(s) for s in parser.ds.files))
# run all enqueued tasks, get a Dataset
# this typically performs up to two HTTP requests
ds = await parser.run_all()
# sort lessons, because why not
lessons = sorted(ds.lessons, key=lambda x: (x.weekday, x.number))
# print lessons for a specific class
print("\n".join(str(s) for s in lessons if s.register_.name == "1A"))
Check if Edupage exists
async with EdupageApi() as api:
exists = await api.v1.check_edupage("edupagename")
Join a portal account to another Edupage
async with EdupageApi() as api:
# join a new Edupage to a portal account
# (effectively creating a guest account on that Edupage)
account = await api.v2.join_account(portal, "edupagename")
print(repr(account))
# get a session for the just-created account
session = await api.login(**account.dict())
Create a Portal account interactively
async with EdupageApi() as api:
await api.register_interactive()
Command-line scripts
Available after installing the package (if scripts directory is in your PATH
, or you're using a virtualenv).
$ edupage check guests
Edupage 'guests' exists.
$ edupage register
Enter e-mail address: ...
$ edupage login email@example.com PortalPassword
Portal(user_id=12345, user_email='email@example.com', sessions=[])
Sessions saved to edupage.json
$ edupage join edupagename
Logged in as 'email@example.com'
New account:
Account(...)
Re-login to use the session
$ edupage parse othername --register 1A
Parsing 'edupage://othername/get/...'
Lesson(...)
Lesson(...)
...
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file timetables-parser-edupage-1.0.0.tar.gz
.
File metadata
- Download URL: timetables-parser-edupage-1.0.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.10.0 Linux/5.11.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 562f60a29948c56b6238ef18b6932fe9f4cfa2d58a9e7c94c9941733a27ebc2e |
|
MD5 | ca6bcb57d742ae7d067462281660a97a |
|
BLAKE2b-256 | da187672da5a8b515839bfbecdb5e160c09043936c176400b78fa36309b93743 |
File details
Details for the file timetables_parser_edupage-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: timetables_parser_edupage-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.10.0 Linux/5.11.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4872835d166bf5761ea9153dc0ad31bf6b123baf6c0bef3794393f365542f0bf |
|
MD5 | 20e7d2b8724cfd6eb23641765d529030 |
|
BLAKE2b-256 | 046a49c2e227582a55dbbf9534753beaa44c09fbc203723ad9c90ecdc5cd4c5d |