Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Lecture Watcher

A small utility for monitoring the University of Science and Technology of China (USTC) graduate lecture portal. The watcher authenticates against the CAS login page, loads the lecture selection table, tracks the records in a local cache, and notifies you when new lectures are published.

Features

  • CAS login automation for https://yjs1.ustc.edu.cn/gsapp/
  • HTML parsing of the academic report selection table
  • JSON cache to avoid duplicate notifications
  • Optional SMTP notification when new lectures are found
  • Continuous watch loop with configurable polling interval

Installation

Create a virtual environment and install the dependencies:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

If you prefer not to create a requirements file, install the minimal dependencies manually:

pip install requests beautifulsoup4

Configuration

The watcher uses environment variables for credentials and optional email notifications:

Variable Description
USTC_USERNAME Your USTC campus ID used for CAS login.
USTC_PASSWORD Password associated with the campus ID.
LECTURE_NOTIFY_EMAIL (Optional) Recipient email for notifications.
LECTURE_SMTP_SERVER (Optional) SMTP server hostname. Required if LECTURE_NOTIFY_EMAIL is set.
LECTURE_SMTP_PORT (Optional) SMTP port; defaults to 587.
LECTURE_SMTP_USERNAME (Optional) SMTP username for authenticated SMTP servers.
LECTURE_SMTP_PASSWORD (Optional) SMTP password.
LECTURE_POLL_INTERVAL (Optional) Poll interval in seconds; defaults to 600.

Credentials are not stored on disk by default. If you need persistent configuration, consider exporting the variables in your shell profile or using a .env loader.

Usage

Run the watcher with Python once the environment variables are configured:

export USTC_USERNAME="your_id"
export USTC_PASSWORD="your_password"
python scripts/lecture_watcher.py

The script will:

  1. Log into the CAS portal using the provided credentials.
  2. Establish a session with the graduate school service portal.
  3. Load the academic report selection page and parse the lecture table.
  4. Compare the result with storage/lectures.json to detect new or modified entries.
  5. Emit an info-level log message and optional email whenever updates are detected.
  6. Sleep for the configured interval and repeat the cycle.

To run the watcher in the background you can rely on process managers (e.g. systemd, supervisor, tmux) or containerize the script. The process emits structured logs which make it suitable for integration with log aggregators.

Development

  • scripts/lecture_watcher.py contains the main implementation.
  • The module can be imported and the LectureWatcher class used directly in custom tooling if you prefer to integrate it into a larger project.

To validate the script without hitting the live service you can mock the network requests by patching CASClient.session with a custom object that returns saved HTML fixtures.

Disclaimer

This project is intended for personal use. Please respect the university's terms of service and rate limits when running the watcher.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages