Course - 北大教学网 CLI
A CLI client for PKU's Blackboard Learn teaching platform.
Architecture
- Crate location:
crates/course/ - Auth flow: IAAA SSO (
app_id="blackboard") → Blackboard SSO endpoint callback - API: HTML scraping with
scrapercrate (no JSON API available) - File upload: multipart form via reqwest
Key Source Files
src/main.rs— Clap CLI with subcommandssrc/commands.rs— Command implementationssrc/api.rs— HTML scraping logic, page parserssrc/display.rs— Terminal output formattingsrc/client.rs— reqwest client builders
CLI Commands
| Command | Alias | Function |
|---|---|---|
login / logout / status | IAAA → Blackboard auth | |
courses | List enrolled courses (supports --all for all semesters) | |
info | Course details | |
content | Browse course content tree | |
assignments | List assignments with deadlines | |
assignment | View single assignment | |
browse | Interactive course content browser | |
assignment-download | adl | Download assignment attachments |
download | Download course files | |
video-download | vdl | Download course recordings |
videos | vls | List available videos |
submit | Upload homework files | |
otp | TOTP 2FA management |
Auto-Login for AI Agents
# Check session status
info-auth check
# Auto-login (reads credentials from OS keyring, no password needed)
course login -p
Development Notes
- HTML parsing is the primary data extraction method — no REST API
- Assignment list supports deadline-based sorting
- Video download handles replay/recording URLs
- All user-facing strings in Chinese
- Error handling:
anyhow::Resultwith.context("中文描述") - Session persisted to
~/.config/info/course/ - Credentials resolved via
info_common::credential(keyring → env → interactive)