This script scrapes your Gradescope account for courses and assignment details. Assignment details currently can be transferred to iCalendar events (and then imported to other calendar applications such as Google Calendar). Another method exists to write these assignment details directly to a Google Calendar but requires additional setup. Scraping the Gradescope website is largely based off of the projects this is forked from.
- Python 3.7 or above
Windows
python -m venv .venv
.venv/Scripts/activate
pip install gradescopecalendar
Mac/Linux
python3 -m venv venv
source venv/bin/activate
pip3 install gradescopecalendar
Windows
pip install --upgrade gradescopecalendar
Mac/Linux
pip3 install --upgrade gradescopecalendar
These steps are only necessary if you wish to install or work on the development version.
Windows
git clone https://github.com/calvinatian/gradescope-calendar.git
cd gradescope-calendar
python -m venv .venv
.venv/Scripts/activate
pip install -r requirements.txt
Mac/Linux
git clone https://github.com/calvinatian/gradescope-calendar.git
cd gradescope-calendar
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
Copy paste the below code or use the example script located at example.py
. Modify the EMAIL
and PASSWORD
fields with your Gradescope account information then run the script.
from gradescopecalendar.gradescopecalendar import GradescopeCalendar
import logging
if __name__ == "__main__":
# ------------------------------------------------------------ #
# Modify these two fields with your Gradescope account details #
EMAIL = ""
PASSWORD = ""
IS_INSTRUCTOR = False # If you are an instructor for **any** course,
# modify this to True.
# Modify these for logging
LOGGING_ENABLED = True
LOGGING_LEVEL = logging.DEBUG
# Valid logging levels
# logging.INFO, logging.DEBUG, logging.WARN, logging.CRITICAL
# ------------------------------------------------------------ #
logger = logging.getLogger("gradescopecalendar" if LOGGING_ENABLED else None)
logger.setLevel(LOGGING_LEVEL)
calendar = GradescopeCalendar(EMAIL, PASSWORD, IS_INSTRUCTOR)
calendar.write_to_ical()
# Uncomment below to update Google Calendar directly
# calendar.write_to_gcal()
Details about the application are written to the log file gradescopecalendar.log
if enabled.
Windows task scheduler can be used to automatically run the script at a specified interval. This can be done by creating a new task and setting the trigger to run the script at a specified interval. When creating the task you should see a window with 5 tabs: General, Triggers, Actions, Conditions, and Settings. The following steps will walk you through the process of creating a task to run the script every day at 8:00 AM and every time you unlock your device. An additional condition will be added so the previous triggers will only execute if the computer has been idle for 10 minutes.
General information about the task
- Give the task a name and description.
- Everything else can be left as default.
The trigger is what will cause the task to run. In this case we want the task to run every day at 8:00 AM and when we unlock the device.
- Click "New".
- Select "Daily" and set the time to 8:00 AM.
- The other settings can be left default but feel free to change them if you want.
- Click "OK".
- Click "New".
- At the top in the "Begin the task" dropdown select "On workstation unlock".
- Click "OK".
This is where we will specify the program to run and the arguments to pass to the program.
- Click "New".
- For the "Program/script" field, navigate to your
python.exe
executable location. If you are using a virtual environment, it would be\PATH\TO\FOLDER\.venv\Scripts\python.exe
. - In the arguments field you should specify the path to the script. For example, if the script is located in
C:\Users\user\gradescope-calendar\example.py
then the arguments would beC:\Users\user\gradescope-calendar\example.py
. - The "Start in" field should be the path to the folder containing the script. For example, if the script is located in
C:\Users\user\gradescope-calendar\example.py
then the "Start in" field would beC:\Users\user\gradescope-calendar
. - Click "OK".
This is where we will specify the conditions that must be met for the task to run. In this case we want the task to run only if the computer has been idle for 10 minutes.
- Click "New".
- Select "Start the task only if the computer is idle for" and change the time to 10 minutes.
- Uncheck "Stop if the computer ceases to be idle"
- Check the box under Network to "Start only if the following network connection is available".
- Click "OK".
This is where we will specify additional settings for the task.
- Click "New".
- Select "Run task as soon as possible after a scheduled start is missed".
- Click "OK".
The task should now be scheduled to run every day at 8:00 AM and every time you unlock your device only if the device has been idle for 10 minutes. By default, it will wait up to 1 hour for this condition to come true (feel free to change the time in the "Conditions" tab). If it misses the scheduled start time it will run as soon as possible after the scheduled start time is missed.
Cron
Launchd
- Goto the Google Cloud Platform and create a new project.
- From the sidebar click "APIs & Services" and then "Dashboard".
- At the top of the page click "Enable API and Services".
- Scroll down to the Google Calendar API and enable it.
- Goto the sidebar and click on "OAuth consent screen".
- Click on "External".
- Fill in the App information. Since this API instance will only be used by yourself it does not really matter what you fill in.
- You can skip filling in the "Scopes" section. Just click "Save and Continue".
- On the "Test users" add the email(s) you want to modify the calendars for. If you are paranoid about the script altering your private calendar details you can create a new Google account and add that instead. Then you can share that calendar to other Google accounts.
- On the sidebar goto the "Credentials" tab and create a new "OAuth Client ID".
- Select Desktop app for Application type and give it any name.
- Once the ID has been created, click the "Download JSON" button and save the file to your computer as
credentials.json
and move it to where you are usinggradescopecalendar
. - You can now uncomment the line for writing to Google Calendar and run the script.
- On first run you will be prompted to login and grant access to your account for the project. This will create a
token.json
in the folder granting access to the script to modify your calendar. No one should be able to access your account if this file is kept secure. As mentioned earlier, you can also create a new Google account and use that calendar instead. Then you can share that calendar with your other Google accounts. - You might notice nothing being printed to the console when running the script. This is intentional. Enable logging and check the
gradescopecalendar.log
for details about the script progress. - The first run of writing to Google Calendar may take a while depending on how many assignments there are to create/modify. Subsequent runs should be much faster as only new or updated assignments will be created/modified.
- Calendar events on the Gradescope calendar are never deleted, only created or updated. If the name of an assignment changes a new event will be created with the new name. Otherwise, if the start/end time or the location (URL of the assignment) of the event differ between Gradescope and Google Calendar, the event will be updated with the values from Gradescope. All other fields such as the description should remain unchanged.
There is support for both VEVENT
and VTODO
in CalDAV. If you have todo=True
ensure that your CalDAV server has VTODO support.
- More use options such as the naming format of the events and how much to offset the start time by (currently start time is the same as end time).
- Ability to add custom reminders for Google Calendar events.