Help us shape the future of Go! Take the 2026 Go Developer Survey

sjtu-canvas-cli

module
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT

README

SJTU-Canvas CLI

这是一个汇总了上海交通大学学习平台接口的CLI。

你可以在脚本中组合使用这些接口,实现特定任务;你也可以将其作为UI后端。

Screenshot 2026-10-02 at 14 44 33

可用的操作系统

本软件仅适配macOS和使用systemd的GNU/Linux。桌面和无桌面环境下均可使用。

在桌面环境下,你的登录凭证会被存放在keychain中;安全性相对较高。

在桌面环境下,若daemon登录凭证出现问题,你会叮到咚鸡。

安装

curl -fsSL https://soft.mahiro.ink/sjtu-install.sh | sh

快速开始

  1. 登录:

    sjtu auth canvas login      # 配置 Canvas API Token
    sjtu auth jaccount login    # 扫码登录 jAccount
    
  2. 填写配置(不会写就问AI): 在 ~/.config/sjtu/config.json 中配置视频自检课程 ID 与通知命令:

    {
      "probe": { "video_course_id": 12345 },
      "notify": { "command": ["curl", "-d", "@-", "https://ntfy.sh/your-topic"] }
    }
    
    • video_course_id:12345 仅为示例;请填写你正在修读的课程数字 ID(访问 Canvas 平台打开任意课程,从 URL 末尾即可获取)。
    • notify.command:告警通知命令示例;事件 JSON 通过 stdin 传入,此处以推送至 ntfy 为例,亦可按需调用自定义脚本。
  3. 按需注册常驻服务: 若需复用预热会话加速命令并启用健康监测,可一键注册为系统服务:

    sjtu daemon install
    

鸣谢

感谢MoonshotAI/Kimi-K3和Google/Gemini-3.8-Flash。

Directories

Path Synopsis
cmd
sjtu command
Command sjtu is the CLI entry point for SJTU online services.
Command sjtu is the CLI entry point for SJTU online services.
internal
canvas
Package canvas holds the Canvas API surface: bearer-token validation against the current-user endpoint, plus the course/assignment/file reads backing the vfs.
Package canvas holds the Canvas API surface: bearer-token validation against the current-user endpoint, plus the course/assignment/file reads backing the vfs.
cli
Package cli wires the sjtu command tree.
Package cli wires the sjtu command tree.
config
Package config loads and saves the non-sensitive CLI configuration.
Package config loads and saves the non-sensitive CLI configuration.
cred
Package cred stores and retrieves credentials (Canvas token, jAccount session cookie) through a single Store interface.
Package cred stores and retrieves credentials (Canvas token, jAccount session cookie) through a single Store interface.
daemon
Package daemon runs the sjtu daemon: a purely passive local service that executes the same command implementations as the CLI over HTTP on a unix socket, plus health probes and transition notifications.
Package daemon runs the sjtu daemon: a purely passive local service that executes the same command implementations as the CLI over HTTP on a unix socket, plus health probes and transition notifications.
jaccount
Package jaccount implements QR-code login against SJTU's jAccount SSO and verification of the resulting session cookie.
Package jaccount implements QR-code login against SJTU's jAccount SSO and verification of the resulting session cookie.
logging
Package logging installs the process-wide slog logger: text records appended to the state-directory log file with single-backup rotation, wrapped in credential redaction.
Package logging installs the process-wide slog logger: text records appended to the state-directory log file with single-backup rotation, wrapped in credential redaction.
mlearning
Package mlearning implements the mlearning.sjtu.edu.cn attendance endpoints: the SSO chain that plants the domain's Access_Token cookie, the two read projections behind /courses/<id>/attendance, and the scan-submit write of `sjtu attendance submit`.
Package mlearning implements the mlearning.sjtu.edu.cn attendance endpoints: the SSO chain that plants the domain's Access_Token cookie, the two read projections behind /courses/<id>/attendance, and the scan-submit write of `sjtu attendance submit`.
session
Package session provides authenticated HTTP primitives shared by all SJTU services.
Package session provides authenticated HTTP primitives shared by all SJTU services.
vfs
Package vfs exposes Canvas course content as a read-only io/fs file system.
Package vfs exposes Canvas course content as a read-only io/fs file system.
video
Package video implements the v.sjtu.edu.cn course-video API: the LTI launch chain that yields a per-course jwt-token, the replay and live listings, and the ranged media download path.
Package video implements the v.sjtu.edu.cn course-video API: the LTI launch chain that yields a per-course jwt-token, the replay and live listings, and the ranged media download path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL