monash-study-kit 1.11.0__tar.gz → 1.11.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/CHANGELOG.md +15 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/PKG-INFO +4 -4
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/PRIVACY.md +11 -2
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/README.md +3 -3
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/README.zh-CN.md +3 -3
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/__init__.py +1 -1
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/browser_login.py +6 -2
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/cli.py +46 -8
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/edexport.py +31 -2
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/export.py +17 -6
- monash_study_kit-1.11.2/src/monash_study_kit/folderpick.py +97 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/jobs.py +3 -2
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/paths.py +1 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/pdfrender.py +53 -18
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_course_export.py +11 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_export_pdf.py +118 -0
- monash_study_kit-1.11.2/tests/test_folderpick.py +158 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_security.py +28 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/.github/pull_request_template.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/.github/workflows/release.yml +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/.github/workflows/test.yml +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/.gitignore +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/CODE_OF_CONDUCT.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/CONTRIBUTING.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/LICENSE +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/SECURITY.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/SECURITY-REVIEW-1.5-SCOPE.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/adr/0001-one-shared-core.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/adr/0002-read-only-public-package.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/adr/0003-release-from-a-tag.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/adr/0004-confirmed-mail-and-attendance-actions.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/adr/README.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/gmail-foundation.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/google-and-attendance-setup.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/panels-library-remote.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/releasing.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/screenshots/todo.png +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/docs/security.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/glama.json +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/pyproject.toml +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/scripts/check_dist.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/scripts/measure_tokens.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/scripts/smoke_test.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/skills/monash-study-kit/SKILL.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/__main__.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/attendance.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/attendance_assets/PROVENANCE.md +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/attendance_assets/extract-rows.js +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/attendance_assets/shared.js +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/attendance_auto.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/attendance_evidence.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/attendance_http.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/cdp.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/claude_setup.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/cli_attendance.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/cli_ed.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/cli_gmail.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/cli_google.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/cli_profile.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/clients.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/content_index.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/doctor.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/doctor_deep.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/edlib.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/edquery.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/edsync.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/entry.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/features.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/gmail.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/gmail_tools.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/google_client.json +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/google_export.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/help_menu.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/home.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/htmldom.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/htmlmd.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/lesson_reader.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/lessons.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/library.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/location.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/materials_policy.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/mcp_server.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/mdhtml.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/moodle_content.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/moodlelib.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/output.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/recordings.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/remote.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/semester.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/service_actions.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/service_jobs.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/service_setup.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/student_services.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/student_tools.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/syncer.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/textextract.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/todo.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/transcribe.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/ui/panel.html +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/update_check.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/webnotes.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/src/monash_study_kit/widgets.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/conftest.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_attendance_browser.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_attendance_fast.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_attendance_parity.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_cdp.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_cli.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_clients.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_content_index.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_doctor.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_doctor_deep.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_ed_auth.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_ed_export.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_ed_markdown.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_ed_query.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_ed_quiz.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_ed_tracking.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_feature_cli.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_features.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_gmail.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_google_export.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_help_menu.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_layout.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_lesson_reader.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_library.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_location.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_mcp.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_moodle_content.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_panels.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_profiles.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_recordings.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_remote.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_removed_files.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_semester.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_service_setup.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_setup.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_shared_core.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_skill.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_student_gmail.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_student_tools.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_sync_robustness.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_todo.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_update_check.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_webnotes.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/tests/test_without_ed.py +0 -0
- {monash_study_kit-1.11.0 → monash_study_kit-1.11.2}/uv.lock +0 -0
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Version numbers follow `__version__` in `src/monash_study_kit/__init__.py`: patch for bug fixes, minor for new features.
|
|
4
4
|
|
|
5
|
+
## 1.11.2
|
|
6
|
+
|
|
7
|
+
- Windows PDF browser startup retries once with a fresh isolated profile after an early exit or a startup timeout; each failed process is killed if needed and reaped before retry. Partially written port files and transient connection failures are retried within the startup deadline. A final failure explains the Markdown fallback option.
|
|
8
|
+
- Align the Chinese Gmail privacy summary with the default `gmail.modify` login, and document separate read-only Drive authorization and materials-only profile boundaries in both languages.
|
|
9
|
+
|
|
10
|
+
## 1.11.1
|
|
11
|
+
|
|
12
|
+
- `monash login` no longer crashes with “Browser context management is not supported” when the login window is closed before signing in finishes (on macOS Chrome keeps running without a window); it says the window was closed and how to retry.
|
|
13
|
+
- PDF export on Windows no longer fails when Chrome's helper processes still hold the temporary profile for a moment after closing; cleanup retries and never fails the export.
|
|
14
|
+
- `monash export` says where it is saving up front and shows progress while rendering PDFs and writing the zip, so a long first export no longer looks stuck.
|
|
15
|
+
- `monash export --sync` only syncs Ed Lessons, not forum threads; the package never contained threads.
|
|
16
|
+
- On Windows the default export folder is the system Downloads folder even when it was moved (another drive, OneDrive), instead of falling back to the current directory.
|
|
17
|
+
- `monash export` run in a terminal first opens the system folder picker to choose where to save (defaulting to the last choice, else Downloads), before syncing; `--to` or `--no-ask` skip the dialog, and setting `export_dir` remembers the choice.
|
|
18
|
+
- `monash export` accepts `--refresh-google` (implies `--sync`) to re-export the course's Google files before packaging.
|
|
19
|
+
|
|
5
20
|
## 1.11.0
|
|
6
21
|
|
|
7
22
|
- Course exports now turn Markdown body pages, link lists, quizzes and the index into PDFs by default, keeping original course files. `monash export --format pdf|both|md` overrides the `export_format` setting; synced Markdown and MCP indexing are unchanged.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: monash-study-kit
|
|
3
|
-
Version: 1.11.
|
|
3
|
+
Version: 1.11.2
|
|
4
4
|
Summary: Connect Monash Moodle and Ed to Claude, Codex, Cursor or any local MCP client via a local MCP server and CLI: deadlines, announcements, grades, full-text search over course materials and Ed posts, all on your own machine.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Waldo0926/monash-study-kit
|
|
6
6
|
Project-URL: Issues, https://github.com/Waldo0926/monash-study-kit/issues
|
|
@@ -126,13 +126,13 @@ monash export FIT1045 --sync --json # sync this Moodle unit, then matching Ed u
|
|
|
126
126
|
monash google logout # revoke first, then remove the local token
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
The bundled OAuth client is
|
|
129
|
+
The bundled OAuth client is published but not verified by Google: on first authorization Google shows “Google hasn't verified this app”; choose **Advanced → Go to Monash Student MCP (unsafe)** to continue. Google caps unverified apps at 100 users, and a school-managed account may be blocked by its admins (Google links then stay as links, with the reason in the index). Google classifies `drive.readonly` as a **restricted scope**. It permits reading Drive files; this tool only downloads files linked from courses and does not enumerate your Drive. Google authorization shares the optional `[gmail]` dependency, but uses an independent flow and `secrets/google-drive-token.json` under the data home (`MONASH_KIT_SECRETS` can override the directory). Gmail authorization and `gmail-token.json` are unchanged. Credentials stay in the terminal / browser authorization flow; never paste them into chat.
|
|
130
130
|
|
|
131
131
|
Downloads use read-only GET requests. For Drive export-size or administrator restrictions, a fallback tries the existing Google session in the dedicated login browser. Cookies are used only in memory, never logged or separately saved, and redirects outside Google's domains stop. The fallback may still be blocked by policy; failures keep the original link and explain why. Missing authorization points to `monash google login`. Moodle Page, Resource and assignment `view.php` requests still record a view. Normal folder downloads and Book print requests avoid their `view.php`; the individual-file fallback must open the folder page and records a view.
|
|
132
132
|
|
|
133
133
|
`monash export <unit>` now exports Markdown body pages, link lists, quizzes and the index as **PDF by default**, alongside the original course files. Install Chrome, Edge or Brave to generate PDFs; if no browser is found, the export falls back to Markdown and explains this in the index and terminal. Use `--format both` to include PDF and Markdown, or `--format md` for Markdown only. For example, `monash config export_format both` saves PDF and Markdown as the default. Synced Markdown stays unchanged on your computer for AI, search and MCP. PDF generation runs offline in a fresh temporary browser profile, embeds only local exported images and omits remote images (keeping their alt text). PDFs are cached under `data/pdf-cache/` (up to 500 MB); `--json` includes `pdf.generated`, `pdf.cached` and `pdf.skipped_reason`. `monash ed export` keeps its existing behavior.
|
|
134
134
|
|
|
135
|
-
Every sync checks newly discovered Ed units against tracked Moodle unit codes, including archived units and combined codes such as `FIT1045/FIT1053`; later user tracking choices are preserved. `monash export <unit> --sync` refreshes Moodle first, then matching Ed
|
|
135
|
+
Every sync checks newly discovered Ed units against tracked Moodle unit codes, including archived units and combined codes such as `FIT1045/FIT1053`; later user tracking choices are preserved. `monash export <unit> --sync` refreshes Moodle first, then the matching Ed Lessons (not forum threads), before exporting; `--refresh-google` also re-exports Google files. Run in a terminal, `monash export` first opens the system folder picker to choose where to save (defaulting to your last choice, else Downloads) and then starts; `--to <folder>` or `--no-ask` skip the dialog. It prints the destination and PDF progress as it goes. Ordinary exports use only local data. The README index includes all omission notes and failed Ed images, plus counts of link lists, remote Markdown images, Google links, successful exports and failures grouped by reason; `--json` exposes the same counts in `statistics`.
|
|
136
136
|
|
|
137
137
|
New tests use synthetic HTML / JSON, fake clients and mocked HTTP, with no real account requests. Ed code-challenge workspace downloads still require a real read-only response to establish the interface and are excluded, as are multi-account profiles.
|
|
138
138
|
|
|
@@ -486,7 +486,7 @@ You can also query directly in the terminal without any AI:
|
|
|
486
486
|
| `monash ed lessons FIT2109` / `quiz FIT2109` | Ed lesson progress / quiz questions (for revision) |
|
|
487
487
|
| `monash ed read FIT2109 "W3 Pre-Class"` | A whole lesson as Markdown: text slides, reading pages and PDFs in order, plus its quiz questions |
|
|
488
488
|
| `monash ed export FIT2109 [--module "Week 3"] [--open]` | Zip a unit's Ed materials by week into Downloads |
|
|
489
|
-
| `monash export FIT1043 [--format pdf\|both\|md] [--dir] [--open]` | Export a unit's course materials (Moodle + Ed Lessons) with an index of what was left out and why |
|
|
489
|
+
| `monash export FIT1043 [--sync] [--to DIR\|--no-ask] [--format pdf\|both\|md] [--dir] [--open]` | Export a unit's course materials (Moodle + Ed Lessons) with an index of what was left out and why |
|
|
490
490
|
| `monash config` | View / change settings (restart your AI app afterwards) |
|
|
491
491
|
| `monash connect [client]` | Connect to Codex, Cursor, VS Code, Windsurf or Gemini CLI (see [Other AI clients](#other-ai-clients)) |
|
|
492
492
|
| `monash remote serve` / `pair` / `clients` / `revoke` | Optional remote MCP for ChatGPT and Claude on the web ([Host it yourself](https://docs.secureview.tech/study-kit/remote/)) |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Privacy policy
|
|
2
2
|
|
|
3
|
-
Last updated:
|
|
3
|
+
Last updated: 3 November 2026
|
|
4
4
|
|
|
5
5
|
**English** · [中文摘要](#中文摘要)
|
|
6
6
|
|
|
@@ -14,6 +14,7 @@ Depending on which parts you set up, the software signs in as you and reads:
|
|
|
14
14
|
|
|
15
15
|
- **Moodle** (learning.monash.edu): courses, files, assignments, grades, feedback, announcements, messages and calendar events.
|
|
16
16
|
- **Ed** (edstem.org): posts, replies, lessons and lesson progress.
|
|
17
|
+
- **Google Drive** (optional, separate from Gmail): course-linked Google Docs, Slides, Sheets and Drive files that your account can access, exported to your own machine.
|
|
17
18
|
- **Gmail** (optional): if you connect a Google account, messages, threads, labels and attachments, through the Gmail API.
|
|
18
19
|
- **Attendance** (optional): your attendance records on the university attendance portal.
|
|
19
20
|
|
|
@@ -21,6 +22,12 @@ Gmail access is requested only when you choose to connect it. The package includ
|
|
|
21
22
|
|
|
22
23
|
## How the data is used
|
|
23
24
|
|
|
25
|
+
### Google course files and materials-only profiles
|
|
26
|
+
|
|
27
|
+
`monash google login` requests only `https://www.googleapis.com/auth/drive.readonly`, using a separate `google-drive-token.json` from Gmail's `gmail-token.json`. This scope permits reading all Drive files accessible to the account; the course exporter uses it for files linked from the selected courses. It cannot edit Drive files and does not grant Gmail access. Docs and Slides are exported as PDF (Docs can instead use DOCX); Sheets as XLSX; other Drive files retain their original format. If an API export is blocked or too large, the exporter may try the dedicated login browser's Google session; those cookies stay in memory. An unavailable file remains a link with its failure reason in the export index. `monash google logout` revokes the authorization before deleting the local token; if revocation fails, the token is kept so you can retry.
|
|
28
|
+
|
|
29
|
+
Named `--profile NAME` accounts isolate credentials, databases, materials and browser sessions and always use materials-only mode. This mode skips Gmail, attendance and Ed discussions; named profiles cannot be served remotely or configured into an AI app through `monash connect`. A whole-course export contains teaching materials, including assignment instructions and visible marking guides, but excludes submissions, personal grades, feedback, mail, messages and attendance. Exported files are ordinary local files: review them before sharing.
|
|
30
|
+
|
|
24
31
|
Data is used only to provide the features you use: syncing a private local copy, full-text search, to-do and deadline summaries, and answering questions you ask through an AI app connected to your own instance.
|
|
25
32
|
|
|
26
33
|
The software does not use your data for advertising, does not sell it, and does not use it to build profiles or train machine-learning models.
|
|
@@ -66,7 +73,9 @@ Changes to this policy are published in this file, with the history visible in t
|
|
|
66
73
|
|
|
67
74
|
- 这是开源、自托管的软件:每个人在自己的电脑或自己的服务器上运行,维护者不运营共享服务,也收不到任何人的数据。
|
|
68
75
|
- 数据(课件、帖子、邮件正文与附件)和登录凭据只保存在运行实例的那台机器上,凭据存放在仅本人可读的目录,不保存密码。
|
|
69
|
-
- Gmail
|
|
76
|
+
- Gmail 为可选功能;普通 `monash gmail login` 默认申请 `gmail.modify`,可以读邮件、创建草稿、发送已审阅的草稿和修改标签。只需要读取时用 `monash gmail login --read-only`,申请 `gmail.readonly`。邮箱操作在你确认具体内容后才执行,软件不提供彻底删除邮件的操作。
|
|
77
|
+
- Google 课程文件另用 `monash google login` 授权,独立保存令牌,只申请 `https://www.googleapis.com/auth/drive.readonly`;该权限允许读取账号有权访问的全部 Drive 文件,课程导出器实际处理所选课程中链接的文件,不能修改文件,也不授予 Gmail 权限。Docs、Slides 默认导出 PDF(Docs 可改 DOCX),Sheets 导出 XLSX,其他文件保留原格式。API 受限或文件过大时会尝试专用登录浏览器的 Google 会话,Cookie 只在内存中;失败项在索引中保留链接和原因。`monash google logout` 先吊销授权再删除本机令牌,失败则保留令牌供重试。
|
|
78
|
+
- 命名 `--profile NAME` 隔离凭据、数据库、课件和浏览器会话,强制只导课程资料,跳过 Gmail、考勤和 Ed 讨论区;不能远程服务或用 `monash connect` 配置进 AI 软件。整课导出包含作业说明和可见评分标准,但排除个人提交、成绩、反馈、邮件、私信和考勤;导出是普通本地文件,分享前请检查内容。
|
|
70
79
|
- 数据只发给你连接的服务(Moodle、Ed、Google、考勤门户)和你接入的 AI 应用(仅限它代你查询的结果);不用于广告、不出售、不用于训练模型。
|
|
71
80
|
- 使用 Google API 获取的数据遵守 Google API Services User Data Policy 及其 Limited Use 要求。
|
|
72
81
|
- 可随时在 <https://myaccount.google.com/permissions> 撤销 Google 授权,删除数据目录即可清除全部本地数据。
|
|
@@ -90,13 +90,13 @@ monash export FIT1045 --sync --json # sync this Moodle unit, then matching Ed u
|
|
|
90
90
|
monash google logout # revoke first, then remove the local token
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
The bundled OAuth client is
|
|
93
|
+
The bundled OAuth client is published but not verified by Google: on first authorization Google shows “Google hasn't verified this app”; choose **Advanced → Go to Monash Student MCP (unsafe)** to continue. Google caps unverified apps at 100 users, and a school-managed account may be blocked by its admins (Google links then stay as links, with the reason in the index). Google classifies `drive.readonly` as a **restricted scope**. It permits reading Drive files; this tool only downloads files linked from courses and does not enumerate your Drive. Google authorization shares the optional `[gmail]` dependency, but uses an independent flow and `secrets/google-drive-token.json` under the data home (`MONASH_KIT_SECRETS` can override the directory). Gmail authorization and `gmail-token.json` are unchanged. Credentials stay in the terminal / browser authorization flow; never paste them into chat.
|
|
94
94
|
|
|
95
95
|
Downloads use read-only GET requests. For Drive export-size or administrator restrictions, a fallback tries the existing Google session in the dedicated login browser. Cookies are used only in memory, never logged or separately saved, and redirects outside Google's domains stop. The fallback may still be blocked by policy; failures keep the original link and explain why. Missing authorization points to `monash google login`. Moodle Page, Resource and assignment `view.php` requests still record a view. Normal folder downloads and Book print requests avoid their `view.php`; the individual-file fallback must open the folder page and records a view.
|
|
96
96
|
|
|
97
97
|
`monash export <unit>` now exports Markdown body pages, link lists, quizzes and the index as **PDF by default**, alongside the original course files. Install Chrome, Edge or Brave to generate PDFs; if no browser is found, the export falls back to Markdown and explains this in the index and terminal. Use `--format both` to include PDF and Markdown, or `--format md` for Markdown only. For example, `monash config export_format both` saves PDF and Markdown as the default. Synced Markdown stays unchanged on your computer for AI, search and MCP. PDF generation runs offline in a fresh temporary browser profile, embeds only local exported images and omits remote images (keeping their alt text). PDFs are cached under `data/pdf-cache/` (up to 500 MB); `--json` includes `pdf.generated`, `pdf.cached` and `pdf.skipped_reason`. `monash ed export` keeps its existing behavior.
|
|
98
98
|
|
|
99
|
-
Every sync checks newly discovered Ed units against tracked Moodle unit codes, including archived units and combined codes such as `FIT1045/FIT1053`; later user tracking choices are preserved. `monash export <unit> --sync` refreshes Moodle first, then matching Ed
|
|
99
|
+
Every sync checks newly discovered Ed units against tracked Moodle unit codes, including archived units and combined codes such as `FIT1045/FIT1053`; later user tracking choices are preserved. `monash export <unit> --sync` refreshes Moodle first, then the matching Ed Lessons (not forum threads), before exporting; `--refresh-google` also re-exports Google files. Run in a terminal, `monash export` first opens the system folder picker to choose where to save (defaulting to your last choice, else Downloads) and then starts; `--to <folder>` or `--no-ask` skip the dialog. It prints the destination and PDF progress as it goes. Ordinary exports use only local data. The README index includes all omission notes and failed Ed images, plus counts of link lists, remote Markdown images, Google links, successful exports and failures grouped by reason; `--json` exposes the same counts in `statistics`.
|
|
100
100
|
|
|
101
101
|
New tests use synthetic HTML / JSON, fake clients and mocked HTTP, with no real account requests. Ed code-challenge workspace downloads still require a real read-only response to establish the interface and are excluded, as are multi-account profiles.
|
|
102
102
|
|
|
@@ -450,7 +450,7 @@ You can also query directly in the terminal without any AI:
|
|
|
450
450
|
| `monash ed lessons FIT2109` / `quiz FIT2109` | Ed lesson progress / quiz questions (for revision) |
|
|
451
451
|
| `monash ed read FIT2109 "W3 Pre-Class"` | A whole lesson as Markdown: text slides, reading pages and PDFs in order, plus its quiz questions |
|
|
452
452
|
| `monash ed export FIT2109 [--module "Week 3"] [--open]` | Zip a unit's Ed materials by week into Downloads |
|
|
453
|
-
| `monash export FIT1043 [--format pdf\|both\|md] [--dir] [--open]` | Export a unit's course materials (Moodle + Ed Lessons) with an index of what was left out and why |
|
|
453
|
+
| `monash export FIT1043 [--sync] [--to DIR\|--no-ask] [--format pdf\|both\|md] [--dir] [--open]` | Export a unit's course materials (Moodle + Ed Lessons) with an index of what was left out and why |
|
|
454
454
|
| `monash config` | View / change settings (restart your AI app afterwards) |
|
|
455
455
|
| `monash connect [client]` | Connect to Codex, Cursor, VS Code, Windsurf or Gemini CLI (see [Other AI clients](#other-ai-clients)) |
|
|
456
456
|
| `monash remote serve` / `pair` / `clients` / `revoke` | Optional remote MCP for ChatGPT and Claude on the web ([Host it yourself](https://docs.secureview.tech/study-kit/remote/)) |
|
|
@@ -80,7 +80,7 @@ MCP 只注册 `list_files`、`read_file`、`search_content`、`get_ed_lessons`
|
|
|
80
80
|
- Google Slides / Docs 默认导出 PDF,Sheets 导出 XLSX,Drive 普通文件按原格式下载。只处理 Moodle 和 Ed Lessons 里出现过的文件链接;Google 表单不能导出。文件还在时跳过,`monash sync --refresh-google` 强制重新导出。
|
|
81
81
|
- 每次同步检查新出现的 Ed 课程:课号与已跟踪 Moodle 课程相同就自动跟踪,包括归档课程和 `FIT1045/FIT1053` 这样的联合课号;处理过的课程保留用户选择。
|
|
82
82
|
- `monash export <课号>` 导出包里的正文页、链接清单、测验和索引默认是 **PDF(给人看)**,课件原件照常保留。本机同步的 md 不变,继续供 AI、全文搜索和 MCP 使用。用 `--format both` 同时放 PDF 和 md,`--format md` 只放 md;例如 `monash config export_format both` 可将默认值设为同时导出两种格式。需要安装 Chrome / Edge / Brave 才能生成 PDF;没有浏览器时自动回退 md,并在索引和终端说明。PDF 在全新的临时浏览器配置中离线生成,只内嵌本次导出的本地图片,远程图片仅保留替代文字。缓存放在数据目录的 `pdf-cache/`,最多 500 MB;`--json` 新增 `pdf.generated`、`pdf.cached`、`pdf.skipped_reason`。`monash ed export` 的行为不变。
|
|
83
|
-
- `monash export FIT1045 --sync` 先同步这门 Moodle
|
|
83
|
+
- `monash export FIT1045 --sync` 先同步这门 Moodle 课和对应的 Ed Lessons(不抓论坛帖子)再导出;加 `--refresh-google` 会重新导出 Google 文件。在终端里运行 `monash export` 时,会先弹出系统的“选择文件夹”窗口选保存位置(默认上次选的,没有就是“下载”),选好才开始;用 `--to 文件夹` 或 `--no-ask` 跳过弹窗。导出过程中会显示保存位置和 PDF 排版进度。普通导出继续只读本机缓存。README 索引列出未导出内容和原因,并统计链接清单数量、Markdown 远程图片数、Google 总数 / 成功 / 按原因分组的失败数;`--json` 的 `statistics` 提供相同数字。
|
|
84
84
|
|
|
85
85
|
```bash
|
|
86
86
|
# Google 授权依赖与 Gmail 共用,但授权流程和 token 分开
|
|
@@ -94,7 +94,7 @@ monash export FIT1045 --sync --json
|
|
|
94
94
|
monash google logout # 先向 Google 吊销,再删除本机令牌
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
自带 OAuth
|
|
97
|
+
自带 OAuth 客户端已发布、但没有经过 Google 验证:第一次授权时 Google 会提示“Google 尚未验证此应用”,点 **高级 → 转至 Monash Student MCP(不安全)** 继续即可。未验证的应用最多 100 个用户;学校管理的账号也可能被管理员拦下,这时 Google 链接会保留为链接,索引里写明原因。`drive.readonly` 在 Google 属于受限 scope,允许读取 Drive 文件;本工具仅下载课程链接里出现的文件,不遍历整个 Drive。令牌单独存在数据目录的 `secrets/google-drive-token.json`(可通过 `MONASH_KIT_SECRETS` 改位置),不修改 Gmail 的授权流程或 `gmail-token.json`。令牌只在终端 / 浏览器授权流程中流转,不要贴进聊天。
|
|
98
98
|
|
|
99
99
|
课程下载走只读 GET。Drive API 报大小限制或管理员限制时,会尝试专用登录浏览器中已有的 Google 会话;cookie 只在内存使用,不写日志或另存文件,跳转离开 Google 域名会停止。后备路径不能保证绕过管理员限制,仍失败时保留原链接并在索引说明原因。未授权时提示 `monash google login`。Moodle Page、Resource、作业仍会打开 `view.php`,Moodle 会记录查看;文件夹正常下载和 Book 打印视图不打开各自的 `view.php`。文件夹整包下载失败后的逐文件回退需要打开文件夹页,也会记录一次查看。
|
|
100
100
|
|
|
@@ -433,7 +433,7 @@ npx skills add Waldo0926/monash-study-kit
|
|
|
433
433
|
| `monash ed lessons FIT2109` / `quiz FIT2109` | Ed Lessons 进度 / 测验题(复习用) |
|
|
434
434
|
| `monash ed read FIT2109 "W3 Pre-Class"` | 整节 lesson 的正文:文字页、阅读网页、PDF 按页序拼成 Markdown,附测验题 |
|
|
435
435
|
| `monash ed export FIT2109 [--module "Week 3"] [--open]` | 整门课的 Ed 课件按周打包成 zip,存到“下载” |
|
|
436
|
-
| `monash export FIT1043 [--format pdf\|both\|md] [--dir] [--open]` | 导出一门课的课程资料(Moodle + Ed Lessons),附索引,写明没导出的内容和原因 |
|
|
436
|
+
| `monash export FIT1043 [--sync] [--to 文件夹\|--no-ask] [--format pdf\|both\|md] [--dir] [--open]` | 导出一门课的课程资料(Moodle + Ed Lessons),附索引,写明没导出的内容和原因 |
|
|
437
437
|
| `monash config` | 看/改设置(改完重启 AI 软件) |
|
|
438
438
|
| `monash connect [客户端]` | 接进 Codex、Cursor、VS Code、Windsurf 或 Gemini CLI(见[接入其他 AI 客户端](#接入其他-ai-客户端)) |
|
|
439
439
|
| `monash remote serve` / `pair` / `clients` / `revoke` | 可选:给 ChatGPT 和网页版 Claude 用的远程 MCP([自己托管(进阶)](https://docs.secureview.tech/zh-cn/study-kit/remote/)) |
|
|
@@ -157,9 +157,13 @@ def login_moodle(interactive: bool = True, timeout: float = 300, log=print) -> d
|
|
|
157
157
|
time.sleep(1.5)
|
|
158
158
|
try:
|
|
159
159
|
urls = browser.page_urls()
|
|
160
|
+
# Mac 上关掉最后一个窗口,Chrome 进程还在但没有页面了;这时再读 cookie 会报
|
|
161
|
+
# “Browser context management is not supported”,一样当成窗口被关掉
|
|
162
|
+
if interactive and not urls:
|
|
163
|
+
raise LoginFailed("登录窗口被关掉了,没有完成登录(重新运行 monash login,登录完窗口会自己关)")
|
|
160
164
|
jar = browser.cookies()
|
|
161
|
-
except (WebSocketClosed, OSError):
|
|
162
|
-
raise LoginFailed("
|
|
165
|
+
except (WebSocketClosed, OSError, RuntimeError):
|
|
166
|
+
raise LoginFailed("登录窗口被关掉了,没有完成登录(重新运行 monash login,登录完窗口会自己关)") from None
|
|
163
167
|
if not interactive and _on_okta(urls) and time.monotonic() - started > 20:
|
|
164
168
|
raise LoginFailed("自动登录不行(Okta 要重新输入密码或 MFA)")
|
|
165
169
|
session = jar.get("MoodleSession")
|
|
@@ -637,18 +637,20 @@ def cmd_due(args):
|
|
|
637
637
|
return emit_json(items) if want_json(args) else _print_due(items)
|
|
638
638
|
|
|
639
639
|
|
|
640
|
-
def sync_export_course(ref: str, log=print) -> None:
|
|
640
|
+
def sync_export_course(ref: str, log=print, refresh_google: bool = False) -> None:
|
|
641
641
|
"""先同步指定 Moodle 课,再同步对应 Ed 课,最后补导 Ed 的 Google 链接。"""
|
|
642
642
|
from . import google_export
|
|
643
643
|
client, con = MoodleClient(), db_connect()
|
|
644
644
|
try:
|
|
645
645
|
courses = jobs.load_courses(client, con)
|
|
646
646
|
course = F.find_course(courses, ref)
|
|
647
|
-
jobs.sync_moodle(only=[course], log=log)
|
|
647
|
+
jobs.sync_moodle(only=[course], log=log, refresh_google=refresh_google)
|
|
648
648
|
if jobs.have_ed_token():
|
|
649
|
-
|
|
649
|
+
# 导出只要课程资料:只同步 Lessons,不抓论坛帖子
|
|
650
|
+
jobs.sync_ed(log=log, course_code=course_code(course), lessons_only=True)
|
|
650
651
|
econ = edlib.db_connect()
|
|
651
652
|
try:
|
|
653
|
+
# 重新导出已在上面 Moodle 那一轮做过,这里只补 Ed 新出现的链接
|
|
652
654
|
google_export.sync_course(con, course, ed_conn=econ, log=log)
|
|
653
655
|
write_links_md(con, course["id"], course_folder(course))
|
|
654
656
|
finally:
|
|
@@ -659,16 +661,50 @@ def sync_export_course(ref: str, log=print) -> None:
|
|
|
659
661
|
con.close()
|
|
660
662
|
|
|
661
663
|
|
|
664
|
+
def is_terminal() -> bool:
|
|
665
|
+
"""有人在终端前面(不是被 Claude、脚本或管道调用)。"""
|
|
666
|
+
return sys.stdin.isatty() and sys.stdout.isatty()
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def export_destination(args) -> Path | None:
|
|
670
|
+
"""导出前先定保存位置:终端里直接运行时弹窗选(默认上次选的,没有就“下载”),选了就记住。
|
|
671
|
+
返回 None 表示用户点了取消。"""
|
|
672
|
+
from . import edexport, folderpick
|
|
673
|
+
if args.to:
|
|
674
|
+
return Path(args.to).expanduser()
|
|
675
|
+
saved = Path(load_settings().get("export_dir") or "").expanduser()
|
|
676
|
+
initial = saved if str(saved) not in {"", "."} and saved.is_dir() else edexport.default_dir()
|
|
677
|
+
interactive = is_terminal() and not getattr(args, "json", False)
|
|
678
|
+
if args.no_ask or not interactive:
|
|
679
|
+
return initial
|
|
680
|
+
print("请在弹出的窗口里选择导出到哪个文件夹…", file=sys.stderr, flush=True)
|
|
681
|
+
try:
|
|
682
|
+
chosen = folderpick.choose_folder("选择课程资料导出到哪个文件夹", initial)
|
|
683
|
+
except folderpick.Unavailable:
|
|
684
|
+
print(f"弹不出选择窗口,导出到:{initial}(换位置用 --to)", file=sys.stderr)
|
|
685
|
+
return initial
|
|
686
|
+
if chosen is None:
|
|
687
|
+
return None
|
|
688
|
+
save_settings({"export_dir": str(chosen)})
|
|
689
|
+
return chosen
|
|
690
|
+
|
|
691
|
+
|
|
662
692
|
def cmd_export(args):
|
|
663
693
|
"""一门课的 Moodle 课件 + Ed Lessons 合成一份课程资料(zip 或文件夹),附索引。只用本机已同步的数据。"""
|
|
664
694
|
from . import export as X, moodlelib
|
|
695
|
+
dest = export_destination(args)
|
|
696
|
+
if dest is None:
|
|
697
|
+
print("已取消导出", file=sys.stderr)
|
|
698
|
+
return 1
|
|
665
699
|
try:
|
|
666
|
-
|
|
667
|
-
|
|
700
|
+
log = lambda text: print(text, file=sys.stderr, flush=True) # noqa: E731
|
|
701
|
+
refresh_google = getattr(args, "refresh_google", False)
|
|
702
|
+
if getattr(args, "sync", False) or refresh_google:
|
|
703
|
+
sync_export_course(args.course, log=log, refresh_google=refresh_google)
|
|
668
704
|
mcon, econ = moodlelib.db_connect(), edlib.db_connect()
|
|
669
705
|
try:
|
|
670
|
-
d = X.export(args.course,
|
|
671
|
-
export_format=getattr(args, "format", None))
|
|
706
|
+
d = X.export(args.course, dest, as_dir=args.dir, moodle_con=mcon, ed_conn=econ,
|
|
707
|
+
export_format=getattr(args, "format", None), log=log)
|
|
672
708
|
finally:
|
|
673
709
|
mcon.close()
|
|
674
710
|
econ.close()
|
|
@@ -952,10 +988,12 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
952
988
|
p.add_argument("query"); p.add_argument("course", nargs="?"); p.add_argument("--limit", type=int, default=15)
|
|
953
989
|
p = cmd(sub, "export", cmd_export, json_flag=True, help="导出一门课的课程资料(Moodle + Ed Lessons,附索引)")
|
|
954
990
|
p.add_argument("course", help="课号,如 FIT1043")
|
|
955
|
-
p.add_argument("--to", help="
|
|
991
|
+
p.add_argument("--to", help="保存到哪个文件夹(不写就弹窗选,默认上次选的或“下载”)")
|
|
992
|
+
p.add_argument("--no-ask", action="store_true", help="不弹窗,直接存到上次选的文件夹或“下载”")
|
|
956
993
|
p.add_argument("--dir", action="store_true", help="写成文件夹,不打 zip")
|
|
957
994
|
p.add_argument("--open", action="store_true", help="导出后在文件管理器里显示")
|
|
958
995
|
p.add_argument("--sync", action="store_true", help="导出前同步这门 Moodle 和 Ed 课程")
|
|
996
|
+
p.add_argument("--refresh-google", action="store_true", help="同步时重新导出 Google 文件(隐含 --sync)")
|
|
959
997
|
p.add_argument("--format", choices=["pdf", "both", "md"], help="正文格式(默认读取 export_format,初始为 pdf)")
|
|
960
998
|
p = cmd(sub, "media", cmd_media, help="录播:YouTube 字幕、Zoom 录像下载和转写(要装 [media])")
|
|
961
999
|
p.add_argument("--limit", type=int, default=0, help="这次最多转写几个视频")
|
|
@@ -16,6 +16,7 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import os
|
|
18
18
|
import sqlite3
|
|
19
|
+
import sys
|
|
19
20
|
import zipfile
|
|
20
21
|
from datetime import datetime
|
|
21
22
|
from pathlib import Path
|
|
@@ -121,9 +122,37 @@ def write_zip(p: dict, out: BinaryIO) -> dict:
|
|
|
121
122
|
"lessons": len(p["lessons"]), "missing": len(p["missing"])}
|
|
122
123
|
|
|
123
124
|
|
|
125
|
+
def _windows_downloads() -> Path | None:
|
|
126
|
+
"""Windows 的“下载”可能被挪到 D 盘或 OneDrive,按系统登记的位置找。"""
|
|
127
|
+
try:
|
|
128
|
+
import ctypes
|
|
129
|
+
from ctypes import wintypes
|
|
130
|
+
from uuid import UUID
|
|
131
|
+
|
|
132
|
+
class GUID(ctypes.Structure):
|
|
133
|
+
_fields_ = [("Data1", wintypes.DWORD), ("Data2", wintypes.WORD),
|
|
134
|
+
("Data3", wintypes.WORD), ("Data4", ctypes.c_ubyte * 8)]
|
|
135
|
+
|
|
136
|
+
u = UUID("374DE290-123F-4565-9164-39C4925E467B") # FOLDERID_Downloads
|
|
137
|
+
guid = GUID(u.fields[0], u.fields[1], u.fields[2], (ctypes.c_ubyte * 8)(*u.bytes[8:]))
|
|
138
|
+
out = ctypes.c_wchar_p()
|
|
139
|
+
if ctypes.windll.shell32.SHGetKnownFolderPath(ctypes.byref(guid), 0, None, ctypes.byref(out)) != 0:
|
|
140
|
+
return None
|
|
141
|
+
try:
|
|
142
|
+
return Path(out.value)
|
|
143
|
+
finally:
|
|
144
|
+
ctypes.windll.ole32.CoTaskMemFree(out)
|
|
145
|
+
except (AttributeError, OSError, ValueError):
|
|
146
|
+
return None
|
|
147
|
+
|
|
148
|
+
|
|
124
149
|
def default_dir() -> Path:
|
|
125
|
-
|
|
126
|
-
|
|
150
|
+
candidates = [_windows_downloads()] if sys.platform == "win32" else []
|
|
151
|
+
candidates.append(Path.home() / "Downloads")
|
|
152
|
+
for d in candidates:
|
|
153
|
+
if d and d.is_dir():
|
|
154
|
+
return d
|
|
155
|
+
return Path.cwd()
|
|
127
156
|
|
|
128
157
|
|
|
129
158
|
def zip_name(p: dict, module: str | None = None) -> str:
|
|
@@ -236,7 +236,7 @@ def _index(p: Plan) -> str:
|
|
|
236
236
|
|
|
237
237
|
|
|
238
238
|
def plan(course: str, *, moodle_con: sqlite3.Connection | None, ed_conn: sqlite3.Connection | None,
|
|
239
|
-
export_format: str | None = None) -> Plan:
|
|
239
|
+
export_format: str | None = None, log=None) -> Plan:
|
|
240
240
|
export_format = export_format if export_format is not None else load_settings()["export_format"]
|
|
241
241
|
if export_format not in {"pdf", "both", "md"}:
|
|
242
242
|
raise ValueError("export_format 只能是 pdf、both 或 md")
|
|
@@ -261,11 +261,11 @@ def plan(course: str, *, moodle_con: sqlite3.Connection | None, ed_conn: sqlite3
|
|
|
261
261
|
"google_success": sum(reason == "成功" for reason in p.google.values()),
|
|
262
262
|
"google_failed": sum(reasons.values()), "google_failure_reasons": reasons}
|
|
263
263
|
p.entries.insert(0, (f"{p.code}/README.md", _index(p)))
|
|
264
|
-
_pdf_entries(p, export_format)
|
|
264
|
+
_pdf_entries(p, export_format, log)
|
|
265
265
|
return p
|
|
266
266
|
|
|
267
267
|
|
|
268
|
-
def _pdf_entries(p: Plan, export_format: str) -> None:
|
|
268
|
+
def _pdf_entries(p: Plan, export_format: str, log=None) -> None:
|
|
269
269
|
if export_format == "md":
|
|
270
270
|
return
|
|
271
271
|
executable = pdfrender.find_browser()
|
|
@@ -277,6 +277,10 @@ def _pdf_entries(p: Plan, export_format: str) -> None:
|
|
|
277
277
|
return
|
|
278
278
|
originals = dict(p.entries)
|
|
279
279
|
converted = []
|
|
280
|
+
pages = sum(arc.lower().endswith(".md") for arc, _ in p.entries)
|
|
281
|
+
done = 0
|
|
282
|
+
if log:
|
|
283
|
+
log(f"排版 PDF:共 {pages} 页(第一次导出较慢,做过的下次直接复用)")
|
|
280
284
|
with contextlib.ExitStack() as stack:
|
|
281
285
|
renderer = None
|
|
282
286
|
for arc, item in p.entries:
|
|
@@ -313,6 +317,9 @@ def _pdf_entries(p: Plan, export_format: str) -> None:
|
|
|
313
317
|
p.pdf["generated"] += 1
|
|
314
318
|
else:
|
|
315
319
|
p.pdf["cached"] += 1
|
|
320
|
+
done += 1
|
|
321
|
+
if log and (done % 20 == 0 or done == pages):
|
|
322
|
+
log(f" PDF {done}/{pages}")
|
|
316
323
|
if export_format == "both":
|
|
317
324
|
converted.append((arc, item))
|
|
318
325
|
# 缓存可在本次导出过程中被清理,条目保留字节,避免写包时引用失效。
|
|
@@ -359,15 +366,19 @@ def _stats(p: Plan, total: int) -> dict:
|
|
|
359
366
|
|
|
360
367
|
def export(course: str, to: str | Path | None = None, *, as_dir: bool = False,
|
|
361
368
|
moodle_con: sqlite3.Connection | None = None, ed_conn: sqlite3.Connection | None = None,
|
|
362
|
-
export_format: str | None = None) -> dict:
|
|
363
|
-
"""导出到文件夹(默认“下载”)。as_dir=True 写成文件夹,否则一个 zip。"""
|
|
364
|
-
p = plan(course, moodle_con=moodle_con, ed_conn=ed_conn, export_format=export_format)
|
|
369
|
+
export_format: str | None = None, log=None) -> dict:
|
|
370
|
+
"""导出到文件夹(默认“下载”)。as_dir=True 写成文件夹,否则一个 zip。log 给命令行显示进度。"""
|
|
365
371
|
dest_dir = Path(to).expanduser() if to else edexport.default_dir()
|
|
372
|
+
if log:
|
|
373
|
+
log(f"导出到:{dest_dir}")
|
|
374
|
+
p = plan(course, moodle_con=moodle_con, ed_conn=ed_conn, export_format=export_format, log=log)
|
|
366
375
|
dest_dir.mkdir(parents=True, exist_ok=True)
|
|
367
376
|
if as_dir:
|
|
368
377
|
return {"path": str(dest_dir / p.code), **write_dir(p, dest_dir)}
|
|
369
378
|
dest = dest_dir / f"{p.code} 课程资料 {datetime.now().strftime('%Y-%m-%d')}.zip"
|
|
370
379
|
tmp = dest.with_name(dest.name + ".part")
|
|
380
|
+
if log:
|
|
381
|
+
log("打包 zip…")
|
|
371
382
|
try:
|
|
372
383
|
with open(tmp, "wb") as f:
|
|
373
384
|
stats = write_zip(p, f)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""弹出系统自带的“选择文件夹”窗口(导出课程资料前选保存位置)。
|
|
2
|
+
|
|
3
|
+
macOS 用 osascript,Windows 用 PowerShell 的 FolderBrowserDialog,Linux 用 zenity / kdialog。
|
|
4
|
+
都不用额外装东西;弹不出来(SSH、没有桌面)时抛 Unavailable,由调用方改用默认位置。
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
import sys
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
TIMEOUT = 600 # 窗口开着没人管,十分钟后放弃
|
|
15
|
+
|
|
16
|
+
_MAC = [
|
|
17
|
+
"on run argv",
|
|
18
|
+
"activate",
|
|
19
|
+
"return POSIX path of (choose folder with prompt (item 1 of argv) default location (POSIX file (item 2 of argv)))",
|
|
20
|
+
"end run",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
# 提示文字和默认位置走环境变量传进去,命令本身不拼接任何路径
|
|
24
|
+
_WINDOWS = (
|
|
25
|
+
"Add-Type -AssemblyName System.Windows.Forms;"
|
|
26
|
+
"[Console]::OutputEncoding = [Text.Encoding]::UTF8;"
|
|
27
|
+
"$d = New-Object System.Windows.Forms.FolderBrowserDialog;"
|
|
28
|
+
"$d.Description = $env:MONASH_PICK_PROMPT;"
|
|
29
|
+
"$d.SelectedPath = $env:MONASH_PICK_DEFAULT;"
|
|
30
|
+
"$d.ShowNewFolderButton = $true;"
|
|
31
|
+
"$owner = New-Object System.Windows.Forms.Form -Property @{TopMost = $true};"
|
|
32
|
+
"if ($d.ShowDialog($owner) -eq 'OK') { $d.SelectedPath }"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _system() -> str:
|
|
37
|
+
"""mac / windows / linux;单独一个函数,测试里只换它,不动全局的 os.name。"""
|
|
38
|
+
if sys.platform == "darwin":
|
|
39
|
+
return "mac"
|
|
40
|
+
return "windows" if sys.platform == "win32" else "linux"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class Unavailable(Exception):
|
|
44
|
+
"""这台机器上弹不出选择窗口。"""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _run(argv: list[str], env: dict | None = None) -> subprocess.CompletedProcess:
|
|
48
|
+
try:
|
|
49
|
+
return subprocess.run(argv, capture_output=True, timeout=TIMEOUT, env=env,
|
|
50
|
+
stdin=subprocess.DEVNULL)
|
|
51
|
+
except (OSError, subprocess.TimeoutExpired) as e:
|
|
52
|
+
raise Unavailable(str(e)) from None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _text(raw: bytes) -> str:
|
|
56
|
+
return raw.decode("utf-8", "replace").strip()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def choose_folder(prompt: str, initial: Path) -> Path | None:
|
|
60
|
+
"""返回选中的文件夹;用户点了取消返回 None;弹不出来抛 Unavailable。"""
|
|
61
|
+
system = _system()
|
|
62
|
+
if system == "mac":
|
|
63
|
+
argv = ["osascript"]
|
|
64
|
+
for line in _MAC:
|
|
65
|
+
argv += ["-e", line]
|
|
66
|
+
r = _run(argv + [prompt, str(initial)])
|
|
67
|
+
if r.returncode != 0:
|
|
68
|
+
if b"-128" in r.stderr: # 用户点了取消
|
|
69
|
+
return None
|
|
70
|
+
raise Unavailable(_text(r.stderr))
|
|
71
|
+
out = _text(r.stdout)
|
|
72
|
+
elif system == "windows":
|
|
73
|
+
exe = shutil.which("powershell") or shutil.which("pwsh")
|
|
74
|
+
if not exe:
|
|
75
|
+
raise Unavailable("找不到 PowerShell")
|
|
76
|
+
env = {**os.environ, "MONASH_PICK_PROMPT": prompt, "MONASH_PICK_DEFAULT": str(initial)}
|
|
77
|
+
r = _run([exe, "-NoProfile", "-NonInteractive", "-STA", "-Command", _WINDOWS], env=env)
|
|
78
|
+
if r.returncode != 0:
|
|
79
|
+
raise Unavailable(_text(r.stderr))
|
|
80
|
+
out = _text(r.stdout)
|
|
81
|
+
else:
|
|
82
|
+
if not (os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY")):
|
|
83
|
+
raise Unavailable("没有图形界面")
|
|
84
|
+
if shutil.which("zenity"):
|
|
85
|
+
argv = ["zenity", "--file-selection", "--directory", f"--title={prompt}",
|
|
86
|
+
f"--filename={initial}{os.sep}"]
|
|
87
|
+
elif shutil.which("kdialog"):
|
|
88
|
+
argv = ["kdialog", "--getexistingdirectory", str(initial), "--title", prompt]
|
|
89
|
+
else:
|
|
90
|
+
raise Unavailable("没有 zenity 或 kdialog")
|
|
91
|
+
r = _run(argv)
|
|
92
|
+
if r.returncode == 1: # 两者都用 1 表示取消
|
|
93
|
+
return None
|
|
94
|
+
if r.returncode != 0:
|
|
95
|
+
raise Unavailable(_text(r.stderr))
|
|
96
|
+
out = _text(r.stdout)
|
|
97
|
+
return Path(out) if out else None
|
|
@@ -108,10 +108,11 @@ def sync_moodle(log=print, only: list[dict] | None = None, dry_run: bool = False
|
|
|
108
108
|
return total
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
def sync_ed(log=print, course_code: str | None = None) -> dict:
|
|
111
|
+
def sync_ed(log=print, course_code: str | None = None, lessons_only: bool = False) -> dict:
|
|
112
|
+
"""lessons_only:只同步 Lessons 课件,不抓论坛帖子(导出课程资料时用)。"""
|
|
112
113
|
client = edlib.EdClient()
|
|
113
114
|
ids = None
|
|
114
|
-
materials = load_settings().get("materials_only", False)
|
|
115
|
+
materials = lessons_only or load_settings().get("materials_only", False)
|
|
115
116
|
listing = client.courses() if materials or course_code else None
|
|
116
117
|
if course_code:
|
|
117
118
|
ids = [c["id"] for c in listing if course_code.upper() in re.split(r"[/\s]+", (c.get("code") or "").upper())]
|
|
@@ -56,6 +56,7 @@ DEFAULTS = {
|
|
|
56
56
|
"files_dir": "", # 课件放哪;空 = 数据目录下的 files。Windows 路径太长时改成 C:\\Monash 之类
|
|
57
57
|
"browser": "", # 登录窗口用哪个浏览器程序;空 = 自动找 Chrome / Edge / Brave
|
|
58
58
|
"export_format": "pdf", # 课程资料正文导出为 pdf、both(PDF 和 md)或 md
|
|
59
|
+
"export_dir": "", # 课程资料导出到哪;空 = “下载”。每次导出在弹窗里选过就记住
|
|
59
60
|
"google_docs_format": "pdf", # Google Docs 导出格式:pdf 或 docx
|
|
60
61
|
"web_notes": True, # 抓 Moodle / Ed 链接到的课程笔记网页(老师的 github.io 讲义站之类)进全文搜索
|
|
61
62
|
"update_check": True, # 每天查一次 GitHub 上有没有新版本,有就提示
|