-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_lessons.py
More file actions
40 lines (30 loc) · 1.28 KB
/
get_lessons.py
File metadata and controls
40 lines (30 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import FireflyAPI
import datetime
# Replace with your own Authentication Blob
auth_blob = "eyJkZ...UwMSJ9"
# In this example we will try to:
# - Get all your lessons for today.
# - Get all your lessons for this week.
# Lets start by getting your timetable.
user_integration = FireflyAPI.AuthenticatedUser(auth_blob)
timetable = user_integration.get_timetable()
# Now that we have your timetable, lets get all the lessons you have today.
lessons_today = timetable.today()
for lesson in lessons_today:
print(lesson)
# Now let's get the lessons you have this week.
# First we need to set out start and end times:
today = datetime.datetime.now() # This is the time right now
start = today - datetime.timedelta(days=today.weekday()) # Start of this week
end = start + datetime.timedelta(days=6) # End of this week
# Now we can get all the lessons between 'start' and 'end'.
lessons_this_week = timetable.get_lessons(start, end)
for lesson in lessons_today:
print(
f""" {lesson.subject}
Starts: {lesson.start}, Ends: {lesson.end}.
Teachers: {", ".join(lesson.teachers)}.
Class: {", ".join(lesson.lesson_groups)}
Location: {lesson.location}
""")
# For more information on lessons, check the documentation for the Timetable and Lesson objects.