get-class-material 1.0.2__tar.gz → 1.0.3__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.
- {get_class_material-1.0.2 → get_class_material-1.0.3}/PKG-INFO +30 -27
- {get_class_material-1.0.2 → get_class_material-1.0.3}/README.md +29 -26
- {get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/PKG-INFO +30 -27
- {get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/entry_points.txt +1 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/cli.py +12 -6
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/doctor.py +8 -8
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/update_check.py +91 -3
- {get_class_material-1.0.2 → get_class_material-1.0.3}/pyproject.toml +2 -1
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_cli.py +2 -1
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_download_reliability.py +2 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_update_check.py +47 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/LICENSE +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/SOURCES.txt +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/dependency_links.txt +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/requires.txt +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/top_level.txt +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/__init__.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/__main__.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/announcements.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/browser_session.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/canvas_client.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/console.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/cool_video.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/course_pipeline.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/http_io.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/i18n.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/media_naming.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/notebooklm.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/notebooklm_api.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/notebooklm_flow.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/pages.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/session_client.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/spinner.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/spreadsheet_convert.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/storage.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/sync.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/youtube_cookies.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/setup.cfg +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_announcements.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_browser_session.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_canvas_client.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_console.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_cool_video.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_course_pipeline.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_doctor.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_excel_download_import.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_media_naming.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_notebooklm.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_notebooklm_api.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_notebooklm_flow.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_session_client.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_spinner.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_spreadsheet_convert.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_storage.py +0 -0
- {get_class_material-1.0.2 → get_class_material-1.0.3}/tests/test_youtube_cookies.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: get-class-material
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: One-command bulk downloader for NTU COOL (Canvas) course materials — PDFs, lecture videos, and Pages.
|
|
5
5
|
Author-email: jabir <jabir95tsai@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -51,8 +51,11 @@ Dynamic: license-file
|
|
|
51
51
|
|
|
52
52
|
```powershell
|
|
53
53
|
python -m pip install get-class-material
|
|
54
|
-
|
|
54
|
+
get-class-material
|
|
55
55
|
```
|
|
56
|
+
|
|
57
|
+
> 舊指令 `ntu-cool-gcm` 仍可使用,功能完全相同。 / The old `ntu-cool-gcm` command still works.
|
|
58
|
+
|
|
56
59
|
更新到最新版,輸入:
|
|
57
60
|
|
|
58
61
|
```powershell
|
|
@@ -137,7 +140,7 @@ python -m pip install get-class-material
|
|
|
137
140
|
### 第 5 步 — 第一次跑工具
|
|
138
141
|
|
|
139
142
|
```powershell
|
|
140
|
-
|
|
143
|
+
get-class-material
|
|
141
144
|
```
|
|
142
145
|
|
|
143
146
|
第一次跑會花幾分鐘,因為它會幫你裝幾個額外的東西:
|
|
@@ -292,18 +295,18 @@ C:\Users\你\Documents\ntu-cool-gcm_material\
|
|
|
292
295
|
|
|
293
296
|
### 登入過期了
|
|
294
297
|
|
|
295
|
-
**多數情況你不用做任何事** — 直接跑 `
|
|
298
|
+
**多數情況你不用做任何事** — 直接跑 `get-class-material`,工具會在連線時自動發現登入過期,並馬上幫你開瀏覽器重新登入(你會看到「登入已過期,開啟瀏覽器重新登入…」)。
|
|
296
299
|
|
|
297
300
|
如果想手動強制重新登入,也可以加:
|
|
298
301
|
|
|
299
302
|
```powershell
|
|
300
|
-
|
|
303
|
+
get-class-material --refresh-session
|
|
301
304
|
```
|
|
302
305
|
|
|
303
306
|
### 只想下載 PDF,不要影片
|
|
304
307
|
|
|
305
308
|
```powershell
|
|
306
|
-
|
|
309
|
+
get-class-material --skip-youtube --skip-cool-videos
|
|
307
310
|
```
|
|
308
311
|
|
|
309
312
|
下載課程時預設一併抓取所有可見公告(標題、作者、日期與全文),存放於課程資料夾的 `announcements/announcements.md` 與 `announcements/.announcements.json`(隱藏檔)。每次執行會重新抓取,以更新老師修改過的公告;課程總覽亦提供公告連結。可用 `--skip-announcements` 略過。
|
|
@@ -313,7 +316,7 @@ ntu-cool-gcm --skip-youtube --skip-cool-videos
|
|
|
313
316
|
### 換存檔位置
|
|
314
317
|
|
|
315
318
|
```powershell
|
|
316
|
-
|
|
319
|
+
get-class-material --out D:\我的課程
|
|
317
320
|
```
|
|
318
321
|
|
|
319
322
|
預設是在你的「文件 / Documents」資料夾底下的 `ntu-cool-gcm_material/`。
|
|
@@ -337,7 +340,7 @@ ntu-cool-gcm --out D:\我的課程
|
|
|
337
340
|
|
|
338
341
|
```powershell
|
|
339
342
|
# 額外檢查本機內容雜湊 / Verify local SHA-256 before skipping
|
|
340
|
-
|
|
343
|
+
get-class-material --verify-files
|
|
341
344
|
|
|
342
345
|
# 限制並行數 / Limit simultaneous file transfers
|
|
343
346
|
ntu-cool-materials download-course --course-id 57544 --workers 2
|
|
@@ -370,7 +373,7 @@ ntu-cool-materials doctor --fix
|
|
|
370
373
|
### 看自己是哪個版本(回報問題時很有用)
|
|
371
374
|
|
|
372
375
|
```powershell
|
|
373
|
-
|
|
376
|
+
get-class-material --version
|
|
374
377
|
```
|
|
375
378
|
|
|
376
379
|
`doctor` 的最上面也會印出版本號。回報問題時附上版本,會比較好幫你查。
|
|
@@ -417,7 +420,7 @@ ntu-cool-gcm --version
|
|
|
417
420
|
```powershell
|
|
418
421
|
python -m pip install "get-class-material[notebooklm]"
|
|
419
422
|
notebooklm login # 第一次:在跳出的 Chrome 視窗登入 Google
|
|
420
|
-
|
|
423
|
+
get-class-material --notebooklm # 選課、下載,完成後直接匯入
|
|
421
424
|
```
|
|
422
425
|
|
|
423
426
|
已經下載過的課程,執行 `ntu-cool-materials notebooklm` 就能從清單選課匯入。
|
|
@@ -437,9 +440,9 @@ ntu-cool-materials notebooklm
|
|
|
437
440
|
|
|
438
441
|
登入狀態由 `notebooklm-py` 保存在本機。可用 `NOTEBOOKLM_HOME` 或 `--notebooklm-storage` 指定。不要提交或分享登入檔案。程式不會從日常 Chrome 擷取 Cookie;登入失效時請重新執行登入程式。
|
|
439
442
|
|
|
440
|
-
舊版的擴充套件(`--extension`)、自動化瀏覽器(`--browser`)與手動上傳資料夾(`--manual`)已移除。沒有安裝 `notebooklm-py` 時,`
|
|
443
|
+
舊版的擴充套件(`--extension`)、自動化瀏覽器(`--browser`)與手動上傳資料夾(`--manual`)已移除。沒有安裝 `notebooklm-py` 時,`get-class-material` 下載完成後不會詢問匯入,只會提示一次安裝指令;明確加 `--notebooklm` 則會顯示安裝方式並回傳失敗。
|
|
441
444
|
|
|
442
|
-
成功使用本機 API 登入後,會將登入檔的絕對路徑記錄在 `~/.ntu-cool-gcm/notebooklm-storage.json`(只記錄位置,不複製憑證),之後從其他目錄啟動 `
|
|
445
|
+
成功使用本機 API 登入後,會將登入檔的絕對路徑記錄在 `~/.ntu-cool-gcm/notebooklm-storage.json`(只記錄位置,不複製憑證),之後從其他目錄啟動 `get-class-material` 也能沿用。明確指定的登入參數及目前目錄的登入設定仍優先;刪除這個位置紀錄即可取消跨目錄沿用。
|
|
443
446
|
|
|
444
447
|
### CLI 指定課程流程
|
|
445
448
|
|
|
@@ -460,17 +463,17 @@ ntu-cool-materials notebooklm --course-id 60804 --verify-only
|
|
|
460
463
|
|
|
461
464
|
### 互動選課流程
|
|
462
465
|
|
|
463
|
-
1. 執行 `
|
|
466
|
+
1. 執行 `get-class-material`,用自己的台大帳號登入、選課下載。
|
|
464
467
|
2. 下載完成後回答「要將這門課匯入 NotebookLM 嗎?」;預設否,下載不會自動把教材送到 Google。
|
|
465
468
|
3. 回答 `y` 就直接開始 API 匯入:沿用此課程已記錄的筆記本,首次則以課程名稱自動建立。不再選筆記本或二次確認。
|
|
466
469
|
4. 終端機顯示匯入結果與筆記本連結。缺少或過期的登入會提示重新登入;上傳失敗時教材仍會保留。
|
|
467
470
|
|
|
468
|
-
一般 `
|
|
471
|
+
一般 `get-class-material` 指令也會沿用目前目錄 `.secrets`(不存在時使用家目錄 `.ntu-cool-gcm/.secrets`)內的 `notebooklm-api` API 登入。明確指定 `--notebooklm-storage` 或 SDK 的 `NOTEBOOKLM_HOME`/`NOTEBOOKLM_PROFILE`/`NOTEBOOKLM_AUTH_JSON` 時,以指定設定為準。若都沒有本機登入則使用 SDK 的預設設定檔。API 功能需在執行 `get-class-material` 的同一 Python 環境安裝 `get-class-material[notebooklm]`。
|
|
469
472
|
|
|
470
473
|
已有教材的使用者只要執行 `ntu-cool-materials notebooklm`,就能從預設下載目錄選課,
|
|
471
474
|
也可輸入其他資料夾路徑。每位使用者使用自己的帳號與本機設定檔,不需要維護者的 Google 帳號、API key 或 Codex。
|
|
472
475
|
`--no-notebooklm` 可略過下載後的詢問;管線/非互動模式不會自動詢問。
|
|
473
|
-
匯入訊息預設是中文,`notebooklm`、`download-course`、`
|
|
476
|
+
匯入訊息預設是中文,`notebooklm`、`download-course`、`get-class-material` 都可加 `--lang en` 改成英文。
|
|
474
477
|
|
|
475
478
|
```powershell
|
|
476
479
|
# 開啟既有教材匯入引導 / Guided course picker
|
|
@@ -480,7 +483,7 @@ ntu-cool-materials notebooklm
|
|
|
480
483
|
ntu-cool-materials notebooklm --course-dir "C:\教材\課程名稱 (60804)" --guide
|
|
481
484
|
|
|
482
485
|
# 選課、下載後,自動匯入 NotebookLM / Download, then import
|
|
483
|
-
|
|
486
|
+
get-class-material --notebooklm
|
|
484
487
|
|
|
485
488
|
# 指定單一課程 / One course
|
|
486
489
|
ntu-cool-materials download-course --course-id 60804 --notebooklm
|
|
@@ -551,7 +554,7 @@ API 模式使用**非官方 Google 個人版介面**,不是 Enterprise 官方
|
|
|
551
554
|
python -m pip install --upgrade get-class-material
|
|
552
555
|
```
|
|
553
556
|
|
|
554
|
-
已經是最新版的話它不會做任何事,隨時都可以放心跑。想確認自己現在哪一版,打 `
|
|
557
|
+
已經是最新版的話它不會做任何事,隨時都可以放心跑。想確認自己現在哪一版,打 `get-class-material --version`。
|
|
555
558
|
|
|
556
559
|
### Q: 輸入 `python --version` 顯示「無法辨識」/「找不到」
|
|
557
560
|
|
|
@@ -565,7 +568,7 @@ python -m pip install --upgrade get-class-material
|
|
|
565
568
|
|
|
566
569
|
### Q: 顯示「應用程式控制原則已封鎖此檔案」(WinError 4551)
|
|
567
570
|
|
|
568
|
-
Windows 的 Smart App Control / 應用程式控制原則擋下了未簽章的執行檔(例如 `pip.exe`、`
|
|
571
|
+
Windows 的 Smart App Control / 應用程式控制原則擋下了未簽章的執行檔(例如 `pip.exe`、`get-class-material.exe`)。所以本文件一律用 `python -m pip` 安裝與更新;如果連 `get-class-material` 也被擋,改用:
|
|
569
572
|
|
|
570
573
|
```powershell
|
|
571
574
|
python -X utf8 -m ntu_cool_materials pick
|
|
@@ -583,7 +586,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
|
583
586
|
|
|
584
587
|
按 `Y` 確認。然後關掉視窗,正常開一個新的就 OK。
|
|
585
588
|
|
|
586
|
-
### Q: `
|
|
589
|
+
### Q: `get-class-material` 跑下去說 `winget` 找不到
|
|
587
590
|
|
|
588
591
|
`winget` 是 Windows 11 內建的應用程式安裝工具。Windows 10 比較舊版可能沒有。
|
|
589
592
|
|
|
@@ -593,14 +596,14 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
|
593
596
|
1. ffmpeg: <https://www.gyan.dev/ffmpeg/builds/>(下載 `ffmpeg-release-essentials.zip`)
|
|
594
597
|
2. Node.js: <https://nodejs.org/>(下載 LTS 版)
|
|
595
598
|
|
|
596
|
-
裝完關掉 PowerShell 重開,再跑 `
|
|
599
|
+
裝完關掉 PowerShell 重開,再跑 `get-class-material`。
|
|
597
600
|
|
|
598
601
|
### Q: NTU COOL 登入過期了
|
|
599
602
|
|
|
600
|
-
直接再跑一次 `
|
|
603
|
+
直接再跑一次 `get-class-material` 就好 — 工具會自動發現過期並開瀏覽器讓你重新登入。要手動強制的話可以加 `--refresh-session`:
|
|
601
604
|
|
|
602
605
|
```powershell
|
|
603
|
-
|
|
606
|
+
get-class-material --refresh-session
|
|
604
607
|
```
|
|
605
608
|
|
|
606
609
|
### Q: YouTube 影片抓不到 / 失敗很多
|
|
@@ -615,7 +618,7 @@ ntu-cool-gcm --refresh-session
|
|
|
615
618
|
|
|
616
619
|
### Q: 下載到一半中斷怎麼辦
|
|
617
620
|
|
|
618
|
-
**直接再跑一次 `
|
|
621
|
+
**直接再跑一次 `get-class-material`** 即可。
|
|
619
622
|
|
|
620
623
|
- 已記錄完成且版本/本機大小吻合的檔案會跳過。
|
|
621
624
|
- 伺服器支援 Range,且部分檔案具有吻合的 ETag/Last-Modified 時才續傳;無法確認版本時會安全地重新下載。
|
|
@@ -641,7 +644,7 @@ C:\Users\你\Documents\ntu-cool-gcm_material\
|
|
|
641
644
|
可以:
|
|
642
645
|
|
|
643
646
|
```powershell
|
|
644
|
-
|
|
647
|
+
get-class-material --skip-pages --skip-youtube --skip-cool-videos
|
|
645
648
|
```
|
|
646
649
|
|
|
647
650
|
### Q: 可以換輸出資料夾嗎
|
|
@@ -649,7 +652,7 @@ ntu-cool-gcm --skip-pages --skip-youtube --skip-cool-videos
|
|
|
649
652
|
可以:
|
|
650
653
|
|
|
651
654
|
```powershell
|
|
652
|
-
|
|
655
|
+
get-class-material --out D:\我的課程資料夾
|
|
653
656
|
```
|
|
654
657
|
|
|
655
658
|
### Q: 影片畫質好像不太好
|
|
@@ -692,7 +695,7 @@ NTU 上課影片(cool-video)畫質維持來源原檔。
|
|
|
692
695
|
- ❌ **不要**分享給別人,連同學也不要
|
|
693
696
|
- ❌ **不要**上傳到 GitHub、雲端硬碟、Discord
|
|
694
697
|
- ❌ **不要**截圖貼到聊天室
|
|
695
|
-
- ✅ 換電腦就重新跑 `
|
|
698
|
+
- ✅ 換電腦就重新跑 `get-class-material --refresh-session` 重新登入即可
|
|
696
699
|
|
|
697
700
|
預設它是隱藏資料夾(Windows 用 `dir` 看不到,要在檔案總管開「顯示隱藏檔」才看得到)。
|
|
698
701
|
|
|
@@ -720,7 +723,7 @@ ntu-cool-materials announcements --course-id 57544 --refresh-session --print
|
|
|
720
723
|
|
|
721
724
|
```powershell
|
|
722
725
|
ntu-cool-materials --help
|
|
723
|
-
|
|
726
|
+
get-class-material --help
|
|
724
727
|
```
|
|
725
728
|
|
|
726
729
|
---
|
|
@@ -14,8 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
```powershell
|
|
16
16
|
python -m pip install get-class-material
|
|
17
|
-
|
|
17
|
+
get-class-material
|
|
18
18
|
```
|
|
19
|
+
|
|
20
|
+
> 舊指令 `ntu-cool-gcm` 仍可使用,功能完全相同。 / The old `ntu-cool-gcm` command still works.
|
|
21
|
+
|
|
19
22
|
更新到最新版,輸入:
|
|
20
23
|
|
|
21
24
|
```powershell
|
|
@@ -100,7 +103,7 @@ python -m pip install get-class-material
|
|
|
100
103
|
### 第 5 步 — 第一次跑工具
|
|
101
104
|
|
|
102
105
|
```powershell
|
|
103
|
-
|
|
106
|
+
get-class-material
|
|
104
107
|
```
|
|
105
108
|
|
|
106
109
|
第一次跑會花幾分鐘,因為它會幫你裝幾個額外的東西:
|
|
@@ -255,18 +258,18 @@ C:\Users\你\Documents\ntu-cool-gcm_material\
|
|
|
255
258
|
|
|
256
259
|
### 登入過期了
|
|
257
260
|
|
|
258
|
-
**多數情況你不用做任何事** — 直接跑 `
|
|
261
|
+
**多數情況你不用做任何事** — 直接跑 `get-class-material`,工具會在連線時自動發現登入過期,並馬上幫你開瀏覽器重新登入(你會看到「登入已過期,開啟瀏覽器重新登入…」)。
|
|
259
262
|
|
|
260
263
|
如果想手動強制重新登入,也可以加:
|
|
261
264
|
|
|
262
265
|
```powershell
|
|
263
|
-
|
|
266
|
+
get-class-material --refresh-session
|
|
264
267
|
```
|
|
265
268
|
|
|
266
269
|
### 只想下載 PDF,不要影片
|
|
267
270
|
|
|
268
271
|
```powershell
|
|
269
|
-
|
|
272
|
+
get-class-material --skip-youtube --skip-cool-videos
|
|
270
273
|
```
|
|
271
274
|
|
|
272
275
|
下載課程時預設一併抓取所有可見公告(標題、作者、日期與全文),存放於課程資料夾的 `announcements/announcements.md` 與 `announcements/.announcements.json`(隱藏檔)。每次執行會重新抓取,以更新老師修改過的公告;課程總覽亦提供公告連結。可用 `--skip-announcements` 略過。
|
|
@@ -276,7 +279,7 @@ ntu-cool-gcm --skip-youtube --skip-cool-videos
|
|
|
276
279
|
### 換存檔位置
|
|
277
280
|
|
|
278
281
|
```powershell
|
|
279
|
-
|
|
282
|
+
get-class-material --out D:\我的課程
|
|
280
283
|
```
|
|
281
284
|
|
|
282
285
|
預設是在你的「文件 / Documents」資料夾底下的 `ntu-cool-gcm_material/`。
|
|
@@ -300,7 +303,7 @@ ntu-cool-gcm --out D:\我的課程
|
|
|
300
303
|
|
|
301
304
|
```powershell
|
|
302
305
|
# 額外檢查本機內容雜湊 / Verify local SHA-256 before skipping
|
|
303
|
-
|
|
306
|
+
get-class-material --verify-files
|
|
304
307
|
|
|
305
308
|
# 限制並行數 / Limit simultaneous file transfers
|
|
306
309
|
ntu-cool-materials download-course --course-id 57544 --workers 2
|
|
@@ -333,7 +336,7 @@ ntu-cool-materials doctor --fix
|
|
|
333
336
|
### 看自己是哪個版本(回報問題時很有用)
|
|
334
337
|
|
|
335
338
|
```powershell
|
|
336
|
-
|
|
339
|
+
get-class-material --version
|
|
337
340
|
```
|
|
338
341
|
|
|
339
342
|
`doctor` 的最上面也會印出版本號。回報問題時附上版本,會比較好幫你查。
|
|
@@ -380,7 +383,7 @@ ntu-cool-gcm --version
|
|
|
380
383
|
```powershell
|
|
381
384
|
python -m pip install "get-class-material[notebooklm]"
|
|
382
385
|
notebooklm login # 第一次:在跳出的 Chrome 視窗登入 Google
|
|
383
|
-
|
|
386
|
+
get-class-material --notebooklm # 選課、下載,完成後直接匯入
|
|
384
387
|
```
|
|
385
388
|
|
|
386
389
|
已經下載過的課程,執行 `ntu-cool-materials notebooklm` 就能從清單選課匯入。
|
|
@@ -400,9 +403,9 @@ ntu-cool-materials notebooklm
|
|
|
400
403
|
|
|
401
404
|
登入狀態由 `notebooklm-py` 保存在本機。可用 `NOTEBOOKLM_HOME` 或 `--notebooklm-storage` 指定。不要提交或分享登入檔案。程式不會從日常 Chrome 擷取 Cookie;登入失效時請重新執行登入程式。
|
|
402
405
|
|
|
403
|
-
舊版的擴充套件(`--extension`)、自動化瀏覽器(`--browser`)與手動上傳資料夾(`--manual`)已移除。沒有安裝 `notebooklm-py` 時,`
|
|
406
|
+
舊版的擴充套件(`--extension`)、自動化瀏覽器(`--browser`)與手動上傳資料夾(`--manual`)已移除。沒有安裝 `notebooklm-py` 時,`get-class-material` 下載完成後不會詢問匯入,只會提示一次安裝指令;明確加 `--notebooklm` 則會顯示安裝方式並回傳失敗。
|
|
404
407
|
|
|
405
|
-
成功使用本機 API 登入後,會將登入檔的絕對路徑記錄在 `~/.ntu-cool-gcm/notebooklm-storage.json`(只記錄位置,不複製憑證),之後從其他目錄啟動 `
|
|
408
|
+
成功使用本機 API 登入後,會將登入檔的絕對路徑記錄在 `~/.ntu-cool-gcm/notebooklm-storage.json`(只記錄位置,不複製憑證),之後從其他目錄啟動 `get-class-material` 也能沿用。明確指定的登入參數及目前目錄的登入設定仍優先;刪除這個位置紀錄即可取消跨目錄沿用。
|
|
406
409
|
|
|
407
410
|
### CLI 指定課程流程
|
|
408
411
|
|
|
@@ -423,17 +426,17 @@ ntu-cool-materials notebooklm --course-id 60804 --verify-only
|
|
|
423
426
|
|
|
424
427
|
### 互動選課流程
|
|
425
428
|
|
|
426
|
-
1. 執行 `
|
|
429
|
+
1. 執行 `get-class-material`,用自己的台大帳號登入、選課下載。
|
|
427
430
|
2. 下載完成後回答「要將這門課匯入 NotebookLM 嗎?」;預設否,下載不會自動把教材送到 Google。
|
|
428
431
|
3. 回答 `y` 就直接開始 API 匯入:沿用此課程已記錄的筆記本,首次則以課程名稱自動建立。不再選筆記本或二次確認。
|
|
429
432
|
4. 終端機顯示匯入結果與筆記本連結。缺少或過期的登入會提示重新登入;上傳失敗時教材仍會保留。
|
|
430
433
|
|
|
431
|
-
一般 `
|
|
434
|
+
一般 `get-class-material` 指令也會沿用目前目錄 `.secrets`(不存在時使用家目錄 `.ntu-cool-gcm/.secrets`)內的 `notebooklm-api` API 登入。明確指定 `--notebooklm-storage` 或 SDK 的 `NOTEBOOKLM_HOME`/`NOTEBOOKLM_PROFILE`/`NOTEBOOKLM_AUTH_JSON` 時,以指定設定為準。若都沒有本機登入則使用 SDK 的預設設定檔。API 功能需在執行 `get-class-material` 的同一 Python 環境安裝 `get-class-material[notebooklm]`。
|
|
432
435
|
|
|
433
436
|
已有教材的使用者只要執行 `ntu-cool-materials notebooklm`,就能從預設下載目錄選課,
|
|
434
437
|
也可輸入其他資料夾路徑。每位使用者使用自己的帳號與本機設定檔,不需要維護者的 Google 帳號、API key 或 Codex。
|
|
435
438
|
`--no-notebooklm` 可略過下載後的詢問;管線/非互動模式不會自動詢問。
|
|
436
|
-
匯入訊息預設是中文,`notebooklm`、`download-course`、`
|
|
439
|
+
匯入訊息預設是中文,`notebooklm`、`download-course`、`get-class-material` 都可加 `--lang en` 改成英文。
|
|
437
440
|
|
|
438
441
|
```powershell
|
|
439
442
|
# 開啟既有教材匯入引導 / Guided course picker
|
|
@@ -443,7 +446,7 @@ ntu-cool-materials notebooklm
|
|
|
443
446
|
ntu-cool-materials notebooklm --course-dir "C:\教材\課程名稱 (60804)" --guide
|
|
444
447
|
|
|
445
448
|
# 選課、下載後,自動匯入 NotebookLM / Download, then import
|
|
446
|
-
|
|
449
|
+
get-class-material --notebooklm
|
|
447
450
|
|
|
448
451
|
# 指定單一課程 / One course
|
|
449
452
|
ntu-cool-materials download-course --course-id 60804 --notebooklm
|
|
@@ -514,7 +517,7 @@ API 模式使用**非官方 Google 個人版介面**,不是 Enterprise 官方
|
|
|
514
517
|
python -m pip install --upgrade get-class-material
|
|
515
518
|
```
|
|
516
519
|
|
|
517
|
-
已經是最新版的話它不會做任何事,隨時都可以放心跑。想確認自己現在哪一版,打 `
|
|
520
|
+
已經是最新版的話它不會做任何事,隨時都可以放心跑。想確認自己現在哪一版,打 `get-class-material --version`。
|
|
518
521
|
|
|
519
522
|
### Q: 輸入 `python --version` 顯示「無法辨識」/「找不到」
|
|
520
523
|
|
|
@@ -528,7 +531,7 @@ python -m pip install --upgrade get-class-material
|
|
|
528
531
|
|
|
529
532
|
### Q: 顯示「應用程式控制原則已封鎖此檔案」(WinError 4551)
|
|
530
533
|
|
|
531
|
-
Windows 的 Smart App Control / 應用程式控制原則擋下了未簽章的執行檔(例如 `pip.exe`、`
|
|
534
|
+
Windows 的 Smart App Control / 應用程式控制原則擋下了未簽章的執行檔(例如 `pip.exe`、`get-class-material.exe`)。所以本文件一律用 `python -m pip` 安裝與更新;如果連 `get-class-material` 也被擋,改用:
|
|
532
535
|
|
|
533
536
|
```powershell
|
|
534
537
|
python -X utf8 -m ntu_cool_materials pick
|
|
@@ -546,7 +549,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
|
546
549
|
|
|
547
550
|
按 `Y` 確認。然後關掉視窗,正常開一個新的就 OK。
|
|
548
551
|
|
|
549
|
-
### Q: `
|
|
552
|
+
### Q: `get-class-material` 跑下去說 `winget` 找不到
|
|
550
553
|
|
|
551
554
|
`winget` 是 Windows 11 內建的應用程式安裝工具。Windows 10 比較舊版可能沒有。
|
|
552
555
|
|
|
@@ -556,14 +559,14 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
|
556
559
|
1. ffmpeg: <https://www.gyan.dev/ffmpeg/builds/>(下載 `ffmpeg-release-essentials.zip`)
|
|
557
560
|
2. Node.js: <https://nodejs.org/>(下載 LTS 版)
|
|
558
561
|
|
|
559
|
-
裝完關掉 PowerShell 重開,再跑 `
|
|
562
|
+
裝完關掉 PowerShell 重開,再跑 `get-class-material`。
|
|
560
563
|
|
|
561
564
|
### Q: NTU COOL 登入過期了
|
|
562
565
|
|
|
563
|
-
直接再跑一次 `
|
|
566
|
+
直接再跑一次 `get-class-material` 就好 — 工具會自動發現過期並開瀏覽器讓你重新登入。要手動強制的話可以加 `--refresh-session`:
|
|
564
567
|
|
|
565
568
|
```powershell
|
|
566
|
-
|
|
569
|
+
get-class-material --refresh-session
|
|
567
570
|
```
|
|
568
571
|
|
|
569
572
|
### Q: YouTube 影片抓不到 / 失敗很多
|
|
@@ -578,7 +581,7 @@ ntu-cool-gcm --refresh-session
|
|
|
578
581
|
|
|
579
582
|
### Q: 下載到一半中斷怎麼辦
|
|
580
583
|
|
|
581
|
-
**直接再跑一次 `
|
|
584
|
+
**直接再跑一次 `get-class-material`** 即可。
|
|
582
585
|
|
|
583
586
|
- 已記錄完成且版本/本機大小吻合的檔案會跳過。
|
|
584
587
|
- 伺服器支援 Range,且部分檔案具有吻合的 ETag/Last-Modified 時才續傳;無法確認版本時會安全地重新下載。
|
|
@@ -604,7 +607,7 @@ C:\Users\你\Documents\ntu-cool-gcm_material\
|
|
|
604
607
|
可以:
|
|
605
608
|
|
|
606
609
|
```powershell
|
|
607
|
-
|
|
610
|
+
get-class-material --skip-pages --skip-youtube --skip-cool-videos
|
|
608
611
|
```
|
|
609
612
|
|
|
610
613
|
### Q: 可以換輸出資料夾嗎
|
|
@@ -612,7 +615,7 @@ ntu-cool-gcm --skip-pages --skip-youtube --skip-cool-videos
|
|
|
612
615
|
可以:
|
|
613
616
|
|
|
614
617
|
```powershell
|
|
615
|
-
|
|
618
|
+
get-class-material --out D:\我的課程資料夾
|
|
616
619
|
```
|
|
617
620
|
|
|
618
621
|
### Q: 影片畫質好像不太好
|
|
@@ -655,7 +658,7 @@ NTU 上課影片(cool-video)畫質維持來源原檔。
|
|
|
655
658
|
- ❌ **不要**分享給別人,連同學也不要
|
|
656
659
|
- ❌ **不要**上傳到 GitHub、雲端硬碟、Discord
|
|
657
660
|
- ❌ **不要**截圖貼到聊天室
|
|
658
|
-
- ✅ 換電腦就重新跑 `
|
|
661
|
+
- ✅ 換電腦就重新跑 `get-class-material --refresh-session` 重新登入即可
|
|
659
662
|
|
|
660
663
|
預設它是隱藏資料夾(Windows 用 `dir` 看不到,要在檔案總管開「顯示隱藏檔」才看得到)。
|
|
661
664
|
|
|
@@ -683,7 +686,7 @@ ntu-cool-materials announcements --course-id 57544 --refresh-session --print
|
|
|
683
686
|
|
|
684
687
|
```powershell
|
|
685
688
|
ntu-cool-materials --help
|
|
686
|
-
|
|
689
|
+
get-class-material --help
|
|
687
690
|
```
|
|
688
691
|
|
|
689
692
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: get-class-material
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: One-command bulk downloader for NTU COOL (Canvas) course materials — PDFs, lecture videos, and Pages.
|
|
5
5
|
Author-email: jabir <jabir95tsai@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -51,8 +51,11 @@ Dynamic: license-file
|
|
|
51
51
|
|
|
52
52
|
```powershell
|
|
53
53
|
python -m pip install get-class-material
|
|
54
|
-
|
|
54
|
+
get-class-material
|
|
55
55
|
```
|
|
56
|
+
|
|
57
|
+
> 舊指令 `ntu-cool-gcm` 仍可使用,功能完全相同。 / The old `ntu-cool-gcm` command still works.
|
|
58
|
+
|
|
56
59
|
更新到最新版,輸入:
|
|
57
60
|
|
|
58
61
|
```powershell
|
|
@@ -137,7 +140,7 @@ python -m pip install get-class-material
|
|
|
137
140
|
### 第 5 步 — 第一次跑工具
|
|
138
141
|
|
|
139
142
|
```powershell
|
|
140
|
-
|
|
143
|
+
get-class-material
|
|
141
144
|
```
|
|
142
145
|
|
|
143
146
|
第一次跑會花幾分鐘,因為它會幫你裝幾個額外的東西:
|
|
@@ -292,18 +295,18 @@ C:\Users\你\Documents\ntu-cool-gcm_material\
|
|
|
292
295
|
|
|
293
296
|
### 登入過期了
|
|
294
297
|
|
|
295
|
-
**多數情況你不用做任何事** — 直接跑 `
|
|
298
|
+
**多數情況你不用做任何事** — 直接跑 `get-class-material`,工具會在連線時自動發現登入過期,並馬上幫你開瀏覽器重新登入(你會看到「登入已過期,開啟瀏覽器重新登入…」)。
|
|
296
299
|
|
|
297
300
|
如果想手動強制重新登入,也可以加:
|
|
298
301
|
|
|
299
302
|
```powershell
|
|
300
|
-
|
|
303
|
+
get-class-material --refresh-session
|
|
301
304
|
```
|
|
302
305
|
|
|
303
306
|
### 只想下載 PDF,不要影片
|
|
304
307
|
|
|
305
308
|
```powershell
|
|
306
|
-
|
|
309
|
+
get-class-material --skip-youtube --skip-cool-videos
|
|
307
310
|
```
|
|
308
311
|
|
|
309
312
|
下載課程時預設一併抓取所有可見公告(標題、作者、日期與全文),存放於課程資料夾的 `announcements/announcements.md` 與 `announcements/.announcements.json`(隱藏檔)。每次執行會重新抓取,以更新老師修改過的公告;課程總覽亦提供公告連結。可用 `--skip-announcements` 略過。
|
|
@@ -313,7 +316,7 @@ ntu-cool-gcm --skip-youtube --skip-cool-videos
|
|
|
313
316
|
### 換存檔位置
|
|
314
317
|
|
|
315
318
|
```powershell
|
|
316
|
-
|
|
319
|
+
get-class-material --out D:\我的課程
|
|
317
320
|
```
|
|
318
321
|
|
|
319
322
|
預設是在你的「文件 / Documents」資料夾底下的 `ntu-cool-gcm_material/`。
|
|
@@ -337,7 +340,7 @@ ntu-cool-gcm --out D:\我的課程
|
|
|
337
340
|
|
|
338
341
|
```powershell
|
|
339
342
|
# 額外檢查本機內容雜湊 / Verify local SHA-256 before skipping
|
|
340
|
-
|
|
343
|
+
get-class-material --verify-files
|
|
341
344
|
|
|
342
345
|
# 限制並行數 / Limit simultaneous file transfers
|
|
343
346
|
ntu-cool-materials download-course --course-id 57544 --workers 2
|
|
@@ -370,7 +373,7 @@ ntu-cool-materials doctor --fix
|
|
|
370
373
|
### 看自己是哪個版本(回報問題時很有用)
|
|
371
374
|
|
|
372
375
|
```powershell
|
|
373
|
-
|
|
376
|
+
get-class-material --version
|
|
374
377
|
```
|
|
375
378
|
|
|
376
379
|
`doctor` 的最上面也會印出版本號。回報問題時附上版本,會比較好幫你查。
|
|
@@ -417,7 +420,7 @@ ntu-cool-gcm --version
|
|
|
417
420
|
```powershell
|
|
418
421
|
python -m pip install "get-class-material[notebooklm]"
|
|
419
422
|
notebooklm login # 第一次:在跳出的 Chrome 視窗登入 Google
|
|
420
|
-
|
|
423
|
+
get-class-material --notebooklm # 選課、下載,完成後直接匯入
|
|
421
424
|
```
|
|
422
425
|
|
|
423
426
|
已經下載過的課程,執行 `ntu-cool-materials notebooklm` 就能從清單選課匯入。
|
|
@@ -437,9 +440,9 @@ ntu-cool-materials notebooklm
|
|
|
437
440
|
|
|
438
441
|
登入狀態由 `notebooklm-py` 保存在本機。可用 `NOTEBOOKLM_HOME` 或 `--notebooklm-storage` 指定。不要提交或分享登入檔案。程式不會從日常 Chrome 擷取 Cookie;登入失效時請重新執行登入程式。
|
|
439
442
|
|
|
440
|
-
舊版的擴充套件(`--extension`)、自動化瀏覽器(`--browser`)與手動上傳資料夾(`--manual`)已移除。沒有安裝 `notebooklm-py` 時,`
|
|
443
|
+
舊版的擴充套件(`--extension`)、自動化瀏覽器(`--browser`)與手動上傳資料夾(`--manual`)已移除。沒有安裝 `notebooklm-py` 時,`get-class-material` 下載完成後不會詢問匯入,只會提示一次安裝指令;明確加 `--notebooklm` 則會顯示安裝方式並回傳失敗。
|
|
441
444
|
|
|
442
|
-
成功使用本機 API 登入後,會將登入檔的絕對路徑記錄在 `~/.ntu-cool-gcm/notebooklm-storage.json`(只記錄位置,不複製憑證),之後從其他目錄啟動 `
|
|
445
|
+
成功使用本機 API 登入後,會將登入檔的絕對路徑記錄在 `~/.ntu-cool-gcm/notebooklm-storage.json`(只記錄位置,不複製憑證),之後從其他目錄啟動 `get-class-material` 也能沿用。明確指定的登入參數及目前目錄的登入設定仍優先;刪除這個位置紀錄即可取消跨目錄沿用。
|
|
443
446
|
|
|
444
447
|
### CLI 指定課程流程
|
|
445
448
|
|
|
@@ -460,17 +463,17 @@ ntu-cool-materials notebooklm --course-id 60804 --verify-only
|
|
|
460
463
|
|
|
461
464
|
### 互動選課流程
|
|
462
465
|
|
|
463
|
-
1. 執行 `
|
|
466
|
+
1. 執行 `get-class-material`,用自己的台大帳號登入、選課下載。
|
|
464
467
|
2. 下載完成後回答「要將這門課匯入 NotebookLM 嗎?」;預設否,下載不會自動把教材送到 Google。
|
|
465
468
|
3. 回答 `y` 就直接開始 API 匯入:沿用此課程已記錄的筆記本,首次則以課程名稱自動建立。不再選筆記本或二次確認。
|
|
466
469
|
4. 終端機顯示匯入結果與筆記本連結。缺少或過期的登入會提示重新登入;上傳失敗時教材仍會保留。
|
|
467
470
|
|
|
468
|
-
一般 `
|
|
471
|
+
一般 `get-class-material` 指令也會沿用目前目錄 `.secrets`(不存在時使用家目錄 `.ntu-cool-gcm/.secrets`)內的 `notebooklm-api` API 登入。明確指定 `--notebooklm-storage` 或 SDK 的 `NOTEBOOKLM_HOME`/`NOTEBOOKLM_PROFILE`/`NOTEBOOKLM_AUTH_JSON` 時,以指定設定為準。若都沒有本機登入則使用 SDK 的預設設定檔。API 功能需在執行 `get-class-material` 的同一 Python 環境安裝 `get-class-material[notebooklm]`。
|
|
469
472
|
|
|
470
473
|
已有教材的使用者只要執行 `ntu-cool-materials notebooklm`,就能從預設下載目錄選課,
|
|
471
474
|
也可輸入其他資料夾路徑。每位使用者使用自己的帳號與本機設定檔,不需要維護者的 Google 帳號、API key 或 Codex。
|
|
472
475
|
`--no-notebooklm` 可略過下載後的詢問;管線/非互動模式不會自動詢問。
|
|
473
|
-
匯入訊息預設是中文,`notebooklm`、`download-course`、`
|
|
476
|
+
匯入訊息預設是中文,`notebooklm`、`download-course`、`get-class-material` 都可加 `--lang en` 改成英文。
|
|
474
477
|
|
|
475
478
|
```powershell
|
|
476
479
|
# 開啟既有教材匯入引導 / Guided course picker
|
|
@@ -480,7 +483,7 @@ ntu-cool-materials notebooklm
|
|
|
480
483
|
ntu-cool-materials notebooklm --course-dir "C:\教材\課程名稱 (60804)" --guide
|
|
481
484
|
|
|
482
485
|
# 選課、下載後,自動匯入 NotebookLM / Download, then import
|
|
483
|
-
|
|
486
|
+
get-class-material --notebooklm
|
|
484
487
|
|
|
485
488
|
# 指定單一課程 / One course
|
|
486
489
|
ntu-cool-materials download-course --course-id 60804 --notebooklm
|
|
@@ -551,7 +554,7 @@ API 模式使用**非官方 Google 個人版介面**,不是 Enterprise 官方
|
|
|
551
554
|
python -m pip install --upgrade get-class-material
|
|
552
555
|
```
|
|
553
556
|
|
|
554
|
-
已經是最新版的話它不會做任何事,隨時都可以放心跑。想確認自己現在哪一版,打 `
|
|
557
|
+
已經是最新版的話它不會做任何事,隨時都可以放心跑。想確認自己現在哪一版,打 `get-class-material --version`。
|
|
555
558
|
|
|
556
559
|
### Q: 輸入 `python --version` 顯示「無法辨識」/「找不到」
|
|
557
560
|
|
|
@@ -565,7 +568,7 @@ python -m pip install --upgrade get-class-material
|
|
|
565
568
|
|
|
566
569
|
### Q: 顯示「應用程式控制原則已封鎖此檔案」(WinError 4551)
|
|
567
570
|
|
|
568
|
-
Windows 的 Smart App Control / 應用程式控制原則擋下了未簽章的執行檔(例如 `pip.exe`、`
|
|
571
|
+
Windows 的 Smart App Control / 應用程式控制原則擋下了未簽章的執行檔(例如 `pip.exe`、`get-class-material.exe`)。所以本文件一律用 `python -m pip` 安裝與更新;如果連 `get-class-material` 也被擋,改用:
|
|
569
572
|
|
|
570
573
|
```powershell
|
|
571
574
|
python -X utf8 -m ntu_cool_materials pick
|
|
@@ -583,7 +586,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
|
583
586
|
|
|
584
587
|
按 `Y` 確認。然後關掉視窗,正常開一個新的就 OK。
|
|
585
588
|
|
|
586
|
-
### Q: `
|
|
589
|
+
### Q: `get-class-material` 跑下去說 `winget` 找不到
|
|
587
590
|
|
|
588
591
|
`winget` 是 Windows 11 內建的應用程式安裝工具。Windows 10 比較舊版可能沒有。
|
|
589
592
|
|
|
@@ -593,14 +596,14 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
|
593
596
|
1. ffmpeg: <https://www.gyan.dev/ffmpeg/builds/>(下載 `ffmpeg-release-essentials.zip`)
|
|
594
597
|
2. Node.js: <https://nodejs.org/>(下載 LTS 版)
|
|
595
598
|
|
|
596
|
-
裝完關掉 PowerShell 重開,再跑 `
|
|
599
|
+
裝完關掉 PowerShell 重開,再跑 `get-class-material`。
|
|
597
600
|
|
|
598
601
|
### Q: NTU COOL 登入過期了
|
|
599
602
|
|
|
600
|
-
直接再跑一次 `
|
|
603
|
+
直接再跑一次 `get-class-material` 就好 — 工具會自動發現過期並開瀏覽器讓你重新登入。要手動強制的話可以加 `--refresh-session`:
|
|
601
604
|
|
|
602
605
|
```powershell
|
|
603
|
-
|
|
606
|
+
get-class-material --refresh-session
|
|
604
607
|
```
|
|
605
608
|
|
|
606
609
|
### Q: YouTube 影片抓不到 / 失敗很多
|
|
@@ -615,7 +618,7 @@ ntu-cool-gcm --refresh-session
|
|
|
615
618
|
|
|
616
619
|
### Q: 下載到一半中斷怎麼辦
|
|
617
620
|
|
|
618
|
-
**直接再跑一次 `
|
|
621
|
+
**直接再跑一次 `get-class-material`** 即可。
|
|
619
622
|
|
|
620
623
|
- 已記錄完成且版本/本機大小吻合的檔案會跳過。
|
|
621
624
|
- 伺服器支援 Range,且部分檔案具有吻合的 ETag/Last-Modified 時才續傳;無法確認版本時會安全地重新下載。
|
|
@@ -641,7 +644,7 @@ C:\Users\你\Documents\ntu-cool-gcm_material\
|
|
|
641
644
|
可以:
|
|
642
645
|
|
|
643
646
|
```powershell
|
|
644
|
-
|
|
647
|
+
get-class-material --skip-pages --skip-youtube --skip-cool-videos
|
|
645
648
|
```
|
|
646
649
|
|
|
647
650
|
### Q: 可以換輸出資料夾嗎
|
|
@@ -649,7 +652,7 @@ ntu-cool-gcm --skip-pages --skip-youtube --skip-cool-videos
|
|
|
649
652
|
可以:
|
|
650
653
|
|
|
651
654
|
```powershell
|
|
652
|
-
|
|
655
|
+
get-class-material --out D:\我的課程資料夾
|
|
653
656
|
```
|
|
654
657
|
|
|
655
658
|
### Q: 影片畫質好像不太好
|
|
@@ -692,7 +695,7 @@ NTU 上課影片(cool-video)畫質維持來源原檔。
|
|
|
692
695
|
- ❌ **不要**分享給別人,連同學也不要
|
|
693
696
|
- ❌ **不要**上傳到 GitHub、雲端硬碟、Discord
|
|
694
697
|
- ❌ **不要**截圖貼到聊天室
|
|
695
|
-
- ✅ 換電腦就重新跑 `
|
|
698
|
+
- ✅ 換電腦就重新跑 `get-class-material --refresh-session` 重新登入即可
|
|
696
699
|
|
|
697
700
|
預設它是隱藏資料夾(Windows 用 `dir` 看不到,要在檔案總管開「顯示隱藏檔」才看得到)。
|
|
698
701
|
|
|
@@ -720,7 +723,7 @@ ntu-cool-materials announcements --course-id 57544 --refresh-session --print
|
|
|
720
723
|
|
|
721
724
|
```powershell
|
|
722
725
|
ntu-cool-materials --help
|
|
723
|
-
|
|
726
|
+
get-class-material --help
|
|
724
727
|
```
|
|
725
728
|
|
|
726
729
|
---
|
|
@@ -23,7 +23,7 @@ from .i18n import get_lang, set_lang, t
|
|
|
23
23
|
from .session_client import AUTH_EXPIRED, CanvasSessionClient, read_headers_file
|
|
24
24
|
from .spinner import spinner
|
|
25
25
|
from .storage import ManifestStore
|
|
26
|
-
from .update_check import check_for_update
|
|
26
|
+
from .update_check import auto_update_dependencies, check_for_update, offer_self_update
|
|
27
27
|
from .sync import SyncStats, sync_course_materials
|
|
28
28
|
from . import console
|
|
29
29
|
|
|
@@ -65,6 +65,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
65
65
|
_force_utf8_streams()
|
|
66
66
|
parser = _build_parser()
|
|
67
67
|
args = parser.parse_args(argv)
|
|
68
|
+
args.relaunch_argv = list(sys.argv[1:] if argv is None else argv) # to rerun after a self-update
|
|
68
69
|
|
|
69
70
|
if not getattr(args, "command", None):
|
|
70
71
|
parser.print_help()
|
|
@@ -660,6 +661,8 @@ def _cmd_pick(base_url: str, args: argparse.Namespace) -> int:
|
|
|
660
661
|
_update_thread = threading.Thread(target=_bg_update_check, daemon=True)
|
|
661
662
|
_update_thread.start()
|
|
662
663
|
|
|
664
|
+
# Before ensure_ready: it imports Playwright, which must not be upgraded under it.
|
|
665
|
+
auto_update_dependencies(_secrets_dir())
|
|
663
666
|
if not ensure_ready(headers_path=headers_path, youtube_cookies_path=youtube_cookies,
|
|
664
667
|
state_path=_secrets_dir() / "setup_state.json"):
|
|
665
668
|
return 1
|
|
@@ -667,6 +670,9 @@ def _cmd_pick(base_url: str, args: argparse.Namespace) -> int:
|
|
|
667
670
|
_update_thread.join(timeout=2.0)
|
|
668
671
|
_newer = _update_result.get("latest")
|
|
669
672
|
if _newer:
|
|
673
|
+
rerun_code = offer_self_update(_newer, getattr(args, "relaunch_argv", ["pick"]))
|
|
674
|
+
if rerun_code is not None:
|
|
675
|
+
return rerun_code
|
|
670
676
|
print(t(
|
|
671
677
|
f"\n💡 有新版本 {_newer}(你目前 {_version_string()})。"
|
|
672
678
|
f"更新指令: python -m pip install --upgrade get-class-material\n",
|
|
@@ -695,8 +701,8 @@ def _cmd_pick(base_url: str, args: argparse.Namespace) -> int:
|
|
|
695
701
|
f"Could not create the login folder (access denied): {exc}",
|
|
696
702
|
))
|
|
697
703
|
print(t(
|
|
698
|
-
" → 請改在可寫入的資料夾執行,例如先打 `cd $HOME` 再跑 `
|
|
699
|
-
" → Run from a writable folder, e.g. `cd $HOME` then `
|
|
704
|
+
" → 請改在可寫入的資料夾執行,例如先打 `cd $HOME` 再跑 `get-class-material`。",
|
|
705
|
+
" → Run from a writable folder, e.g. `cd $HOME` then `get-class-material`.",
|
|
700
706
|
))
|
|
701
707
|
return False
|
|
702
708
|
except Exception as exc: # RuntimeError from SSO, or Playwright's own Error
|
|
@@ -1181,14 +1187,14 @@ def _cmd_pick(base_url: str, args: argparse.Namespace) -> int:
|
|
|
1181
1187
|
def pick_main(argv: list[str] | None = None) -> int:
|
|
1182
1188
|
"""Console-script alias: behaves like `ntu-cool-materials pick`.
|
|
1183
1189
|
|
|
1184
|
-
When called from the `ntu-cool-gcm` entry point, argv is None and we forward
|
|
1190
|
+
When called from the `get-class-material` (or legacy `ntu-cool-gcm`) entry point, argv is None and we forward
|
|
1185
1191
|
sys.argv[1:] so flags like `--help` and `--refresh-session` pass through.
|
|
1186
1192
|
"""
|
|
1187
1193
|
forwarded = list(sys.argv[1:]) if argv is None else list(argv)
|
|
1188
1194
|
# `--version`/`-V` would otherwise be forwarded into the `pick` subparser,
|
|
1189
|
-
# which doesn't define it. Handle it here so `
|
|
1195
|
+
# which doesn't define it. Handle it here so `get-class-material -V` works.
|
|
1190
1196
|
if any(arg in ("--version", "-V") for arg in forwarded):
|
|
1191
|
-
print(f"
|
|
1197
|
+
print(f"get-class-material {_version_string()}")
|
|
1192
1198
|
return 0
|
|
1193
1199
|
return main(["pick", *forwarded])
|
|
1194
1200
|
|
|
@@ -204,8 +204,8 @@ def _add_scripts_to_user_path_windows(scripts_dir: Path) -> bool:
|
|
|
204
204
|
)
|
|
205
205
|
if ok:
|
|
206
206
|
print(t(
|
|
207
|
-
" ⚠ 請關掉這個視窗、重新打開,之後就能直接打 `
|
|
208
|
-
" ⚠ Close this window, reopen it, then `
|
|
207
|
+
" ⚠ 請關掉這個視窗、重新打開,之後就能直接打 `get-class-material` 啟動。",
|
|
208
|
+
" ⚠ Close this window, reopen it, then `get-class-material` will work directly.",
|
|
209
209
|
))
|
|
210
210
|
return ok
|
|
211
211
|
|
|
@@ -267,7 +267,7 @@ def _add_scripts_to_user_path_posix(scripts_dir: Path) -> bool:
|
|
|
267
267
|
|
|
268
268
|
block = (
|
|
269
269
|
f"\n{_POSIX_RC_MARKER_BEGIN}\n"
|
|
270
|
-
f"# Added by
|
|
270
|
+
f"# Added by get-class-material doctor so the `get-class-material` command resolves.\n"
|
|
271
271
|
f"# Remove this block to undo.\n"
|
|
272
272
|
f'export PATH="$PATH:{scripts_dir}"\n'
|
|
273
273
|
f"{_POSIX_RC_MARKER_END}\n"
|
|
@@ -296,8 +296,8 @@ def _add_scripts_to_user_path_posix(scripts_dir: Path) -> bool:
|
|
|
296
296
|
|
|
297
297
|
print(f" ✓ 已把 {scripts_dir} 加進 {rc_path}")
|
|
298
298
|
print(t(
|
|
299
|
-
f" ⚠ 請執行 `source {rc_path}` 或開新的終端機,之後就能直接打 `
|
|
300
|
-
f" ⚠ Run `source {rc_path}` or open a new terminal, then `
|
|
299
|
+
f" ⚠ 請執行 `source {rc_path}` 或開新的終端機,之後就能直接打 `get-class-material`。",
|
|
300
|
+
f" ⚠ Run `source {rc_path}` or open a new terminal, then `get-class-material` will work directly.",
|
|
301
301
|
))
|
|
302
302
|
return True
|
|
303
303
|
|
|
@@ -477,7 +477,7 @@ def _scripts_on_path_fix_hint(scripts_dir: Path) -> str:
|
|
|
477
477
|
|
|
478
478
|
def check_scripts_on_path() -> CheckResult:
|
|
479
479
|
"""Python's scripts dir must be on PATH or pip's entry-point shims
|
|
480
|
-
(`
|
|
480
|
+
(`get-class-material` etc.) won't resolve from a fresh shell.
|
|
481
481
|
|
|
482
482
|
Cross-platform since 0.2.7: previously Windows-only, but the same
|
|
483
483
|
pitfall hits Mac users who install Python from the python.org installer
|
|
@@ -515,7 +515,7 @@ def check_ntu_session(headers_path: Path) -> CheckResult:
|
|
|
515
515
|
ok=False,
|
|
516
516
|
optional=True,
|
|
517
517
|
detail=f"找不到 {headers_path}",
|
|
518
|
-
fix_command="
|
|
518
|
+
fix_command="get-class-material --refresh-session (會開啟瀏覽器讓你登入)",
|
|
519
519
|
)
|
|
520
520
|
age_hr = (time.time() - headers_path.stat().st_mtime) / 3600
|
|
521
521
|
age_label = (
|
|
@@ -641,7 +641,7 @@ def run_doctor(
|
|
|
641
641
|
# name when Playwright itself can't be imported, so both names must block.
|
|
642
642
|
BLOCKING_NAMES = {"Python 3.11 以上", "Playwright (Python 套件)", "Playwright Chromium", "yt-dlp"}
|
|
643
643
|
# "Recommended" — only the YouTube stage needs them (and the PATH entry only
|
|
644
|
-
# shortens `python -m ntu_cool_materials pick` to `
|
|
644
|
+
# shortens `python -m ntu_cool_materials pick` to `get-class-material`). They touch
|
|
645
645
|
# the system (winget/brew, the user's PATH), so they are offered, never forced.
|
|
646
646
|
RECOMMENDED_NAMES = {
|
|
647
647
|
"Node.js (下載 YouTube 影片用)",
|
|
@@ -27,7 +27,7 @@ from pathlib import Path
|
|
|
27
27
|
|
|
28
28
|
from . import console
|
|
29
29
|
|
|
30
|
-
PYPI_JSON_URL = "https://pypi.org/pypi/
|
|
30
|
+
PYPI_JSON_URL = "https://pypi.org/pypi/{package}/json"
|
|
31
31
|
_CHECK_INTERVAL_SEC = 24 * 3600
|
|
32
32
|
_UNKNOWN_VERSION = "0.0.0+unknown"
|
|
33
33
|
|
|
@@ -51,8 +51,8 @@ def is_newer(latest: str, current: str) -> bool:
|
|
|
51
51
|
return _parse_version(latest) > _parse_version(current)
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def _fetch_latest_version(timeout: float) -> str:
|
|
55
|
-
request = urllib.request.Request(PYPI_JSON_URL, headers={"Accept": "application/json"})
|
|
54
|
+
def _fetch_latest_version(timeout: float, package: str = "get-class-material") -> str:
|
|
55
|
+
request = urllib.request.Request(PYPI_JSON_URL.format(package=package), headers={"Accept": "application/json"})
|
|
56
56
|
with urllib.request.urlopen(request, timeout=timeout) as response:
|
|
57
57
|
data = json.loads(response.read().decode("utf-8"))
|
|
58
58
|
return str(data["info"]["version"])
|
|
@@ -252,3 +252,91 @@ def ensure_yt_dlp_updated(
|
|
|
252
252
|
ok, msg = update_yt_dlp(yt_dlp)
|
|
253
253
|
print(f" [yt-dlp] {msg}")
|
|
254
254
|
return ok
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
AUTO_UPDATE_PACKAGES = ("yt-dlp", "playwright")
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def auto_update_dependencies(secrets_dir: Path, *, fetch=None, run=subprocess.run) -> None:
|
|
261
|
+
"""Upgrade yt-dlp / Playwright when PyPI has a newer release.
|
|
262
|
+
|
|
263
|
+
YouTube breaks old yt-dlp within weeks, so staying current matters more
|
|
264
|
+
than asking. PyPI is checked at most once a day per package (same cache
|
|
265
|
+
rules as `check_for_update`). Must run before anything imports Playwright
|
|
266
|
+
in this process. Never raises; a failed upgrade just leaves the old one.
|
|
267
|
+
"""
|
|
268
|
+
import importlib.metadata
|
|
269
|
+
from .i18n import t
|
|
270
|
+
for package in AUTO_UPDATE_PACKAGES:
|
|
271
|
+
try:
|
|
272
|
+
current = importlib.metadata.version(package)
|
|
273
|
+
except Exception:
|
|
274
|
+
continue # not installed: ensure_ready installs it
|
|
275
|
+
latest = check_for_update(
|
|
276
|
+
current,
|
|
277
|
+
cache_path=secrets_dir / f"update_check_{package}.json",
|
|
278
|
+
fetch=(lambda p=package: fetch(p)) if fetch else (lambda p=package: _fetch_latest_version(3.0, p)),
|
|
279
|
+
)
|
|
280
|
+
if not latest:
|
|
281
|
+
continue
|
|
282
|
+
print(t(f" [{package}] 自動更新 {current} → {latest}...",
|
|
283
|
+
f" [{package}] auto-updating {current} → {latest}..."))
|
|
284
|
+
try:
|
|
285
|
+
ok = run([sys.executable, "-m", "pip", "install", "--upgrade", package],
|
|
286
|
+
capture_output=True, text=True, timeout=300).returncode == 0
|
|
287
|
+
if ok and package == "playwright":
|
|
288
|
+
# Each Playwright release pins its own Chromium build; fetch it now
|
|
289
|
+
# (output shown: it's a large download).
|
|
290
|
+
ok = run([sys.executable, "-m", "playwright", "install", "chromium"], timeout=900).returncode == 0
|
|
291
|
+
except Exception:
|
|
292
|
+
ok = False
|
|
293
|
+
print(t(f" [{package}] 已更新" if ok else f" [{package}] 更新失敗,繼續使用 {current}",
|
|
294
|
+
f" [{package}] updated" if ok else f" [{package}] update failed; keeping {current}"))
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def _is_editable_install(package: str = "get-class-material") -> bool:
|
|
298
|
+
"""A dev's `pip install -e .` must not be replaced by the PyPI build."""
|
|
299
|
+
import importlib.metadata
|
|
300
|
+
try:
|
|
301
|
+
raw = importlib.metadata.distribution(package).read_text("direct_url.json")
|
|
302
|
+
return bool(raw and json.loads(raw).get("dir_info", {}).get("editable"))
|
|
303
|
+
except Exception:
|
|
304
|
+
return False
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def offer_self_update(latest: str, relaunch_argv: list[str], *, confirm=None, run=subprocess.run,
|
|
308
|
+
installed_version=None) -> int | None:
|
|
309
|
+
"""Ask [Y/n] to upgrade get-class-material to `latest`, then rerun the same
|
|
310
|
+
command on the new code (modules already imported here are the old ones).
|
|
311
|
+
|
|
312
|
+
Returns the rerun's exit code, or None to carry on with the current
|
|
313
|
+
version (declined, non-interactive, editable install, or upgrade failed).
|
|
314
|
+
"""
|
|
315
|
+
from .i18n import t
|
|
316
|
+
if _is_editable_install():
|
|
317
|
+
return None
|
|
318
|
+
confirm = confirm or confirm_yt_dlp_update
|
|
319
|
+
if not confirm(t(f"\n💡 有新版本 {latest},現在自動更新嗎?[Y/n]: ",
|
|
320
|
+
f"\n💡 Version {latest} is available. Update now? [Y/n]: ")):
|
|
321
|
+
return None
|
|
322
|
+
if installed_version is None:
|
|
323
|
+
import importlib.metadata
|
|
324
|
+
|
|
325
|
+
def installed_version() -> str:
|
|
326
|
+
importlib.invalidate_caches()
|
|
327
|
+
return importlib.metadata.version("get-class-material")
|
|
328
|
+
try:
|
|
329
|
+
ok = run([sys.executable, "-m", "pip", "install", "--upgrade", "get-class-material"]).returncode == 0
|
|
330
|
+
# pip exits 0 without upgrading when the new release needs a newer Python.
|
|
331
|
+
ok = ok and not is_newer(latest, installed_version())
|
|
332
|
+
except Exception:
|
|
333
|
+
ok = False
|
|
334
|
+
if not ok:
|
|
335
|
+
print(t(" 更新失敗,繼續使用目前版本。可手動執行: python -m pip install --upgrade get-class-material",
|
|
336
|
+
" Update failed; continuing with the current version. Run: python -m pip install --upgrade get-class-material"))
|
|
337
|
+
return None
|
|
338
|
+
print(t(f" 已更新到 {latest},重新啟動...\n", f" Updated to {latest}; restarting...\n"))
|
|
339
|
+
try:
|
|
340
|
+
return run([sys.executable, "-m", "ntu_cool_materials", *relaunch_argv]).returncode
|
|
341
|
+
except KeyboardInterrupt:
|
|
342
|
+
return 130
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "get-class-material"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.3"
|
|
8
8
|
description = "One-command bulk downloader for NTU COOL (Canvas) course materials — PDFs, lecture videos, and Pages."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -43,6 +43,7 @@ notebooklm = ["notebooklm-py[browser]==0.8.3", "markitdown[xlsx,xls]>=0.1.2"]
|
|
|
43
43
|
|
|
44
44
|
[project.scripts]
|
|
45
45
|
ntu-cool-materials = "ntu_cool_materials.cli:main"
|
|
46
|
+
get-class-material = "ntu_cool_materials.cli:pick_main"
|
|
46
47
|
ntu-cool-gcm = "ntu_cool_materials.cli:pick_main"
|
|
47
48
|
ntu-cool-video = "ntu_cool_materials.cool_video:main"
|
|
48
49
|
ntu-cool-session = "ntu_cool_materials.browser_session:main"
|
|
@@ -49,7 +49,7 @@ class VersionTests(unittest.TestCase):
|
|
|
49
49
|
with contextlib.redirect_stdout(buf):
|
|
50
50
|
rc = cli.pick_main(["--version"])
|
|
51
51
|
self.assertEqual(rc, 0)
|
|
52
|
-
self.assertIn("
|
|
52
|
+
self.assertIn("get-class-material", buf.getvalue())
|
|
53
53
|
self.assertIn(cli._version_string(), buf.getvalue())
|
|
54
54
|
|
|
55
55
|
def test_pick_main_intercepts_short_V(self) -> None:
|
|
@@ -150,6 +150,7 @@ class PickNotebookLMBatchTests(unittest.TestCase):
|
|
|
150
150
|
|
|
151
151
|
with mock.patch.object(cli, "ensure_ready", return_value=True), \
|
|
152
152
|
mock.patch.object(cli, "check_for_update", return_value=None), \
|
|
153
|
+
mock.patch.object(cli, "auto_update_dependencies"), \
|
|
153
154
|
mock.patch.object(cli, "CanvasSessionClient", return_value=client), \
|
|
154
155
|
mock.patch.object(cli, "read_headers_file", return_value={}), \
|
|
155
156
|
mock.patch.object(cli, "download_course", side_effect=fake_download_course), \
|
|
@@ -365,6 +365,7 @@ class PipelineTests(unittest.TestCase):
|
|
|
365
365
|
(["1", "a", "q"], [failed, success], 0)]:
|
|
366
366
|
with patch.object(cli, "ensure_ready", return_value=True), \
|
|
367
367
|
patch.object(cli, "check_for_update", return_value=None), \
|
|
368
|
+
patch.object(cli, "auto_update_dependencies"), \
|
|
368
369
|
patch.object(cli, "CanvasSessionClient", return_value=self.client), \
|
|
369
370
|
patch.object(cli, "download_course", side_effect=plans) as download, \
|
|
370
371
|
patch("builtins.input", side_effect=replies):
|
|
@@ -389,6 +390,7 @@ class PipelineTests(unittest.TestCase):
|
|
|
389
390
|
"--keep-terminal", *flag])
|
|
390
391
|
with patch.object(cli, "ensure_ready", return_value=True), \
|
|
391
392
|
patch.object(cli, "check_for_update", return_value=None), \
|
|
393
|
+
patch.object(cli, "auto_update_dependencies"), \
|
|
392
394
|
patch.object(cli, "CanvasSessionClient", return_value=self.client), \
|
|
393
395
|
patch.object(cli, "download_course", return_value=plan), \
|
|
394
396
|
patch("ntu_cool_materials.console.stdin_is_interactive", return_value=True), \
|
|
@@ -209,6 +209,53 @@ class YtDlpUpdateTests(unittest.TestCase):
|
|
|
209
209
|
self.assertIn("yt-dlp -U", msg)
|
|
210
210
|
|
|
211
211
|
|
|
212
|
+
class AutoUpdateDependenciesTests(unittest.TestCase):
|
|
213
|
+
def test_upgrades_only_outdated_and_reinstalls_chromium_for_playwright(self) -> None:
|
|
214
|
+
from unittest import mock
|
|
215
|
+
installed = {"yt-dlp": "2026.1.1", "playwright": "1.50.0"}
|
|
216
|
+
latest = {"yt-dlp": "2026.1.1", "playwright": "1.55.0"}
|
|
217
|
+
run = mock.Mock(return_value=mock.Mock(returncode=0))
|
|
218
|
+
with tempfile.TemporaryDirectory() as tmp, \
|
|
219
|
+
mock.patch("importlib.metadata.version", side_effect=installed.__getitem__):
|
|
220
|
+
update_check.auto_update_dependencies(Path(tmp), fetch=latest.__getitem__, run=run)
|
|
221
|
+
cmds = [c.args[0][1:] for c in run.call_args_list]
|
|
222
|
+
self.assertEqual(cmds, [["-m", "pip", "install", "--upgrade", "playwright"],
|
|
223
|
+
["-m", "playwright", "install", "chromium"]])
|
|
224
|
+
|
|
225
|
+
def test_never_raises_when_offline_or_pip_fails(self) -> None:
|
|
226
|
+
from unittest import mock
|
|
227
|
+
def offline(_package):
|
|
228
|
+
raise OSError("offline")
|
|
229
|
+
run = mock.Mock(side_effect=OSError("pip blocked"))
|
|
230
|
+
with tempfile.TemporaryDirectory() as tmp, \
|
|
231
|
+
mock.patch("importlib.metadata.version", return_value="1.0"):
|
|
232
|
+
update_check.auto_update_dependencies(Path(tmp), fetch=offline, run=run)
|
|
233
|
+
update_check.auto_update_dependencies(Path(tmp), fetch=lambda _p: "9.0", run=run)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class OfferSelfUpdateTests(unittest.TestCase):
|
|
237
|
+
def _offer(self, *, answer=True, pip_rc=0, after="1.1.0", editable=False):
|
|
238
|
+
from unittest import mock
|
|
239
|
+
run = mock.Mock(return_value=mock.Mock(returncode=pip_rc))
|
|
240
|
+
with mock.patch("ntu_cool_materials.update_check._is_editable_install", return_value=editable):
|
|
241
|
+
code = update_check.offer_self_update("1.1.0", ["pick", "--out", "x"], confirm=lambda _: answer,
|
|
242
|
+
run=run, installed_version=lambda: after)
|
|
243
|
+
return code, [c.args[0][1:] for c in run.call_args_list]
|
|
244
|
+
|
|
245
|
+
def test_yes_upgrades_then_reruns_same_command(self) -> None:
|
|
246
|
+
code, cmds = self._offer()
|
|
247
|
+
self.assertEqual(code, 0)
|
|
248
|
+
self.assertEqual(cmds, [["-m", "pip", "install", "--upgrade", "get-class-material"],
|
|
249
|
+
["-m", "ntu_cool_materials", "pick", "--out", "x"]])
|
|
250
|
+
|
|
251
|
+
def test_carries_on_without_rerun(self) -> None:
|
|
252
|
+
for kwargs in [dict(answer=False), dict(editable=True), dict(pip_rc=1),
|
|
253
|
+
dict(after="1.0.3")]: # pip "succeeded" but stayed old: no rerun loop
|
|
254
|
+
code, cmds = self._offer(**kwargs)
|
|
255
|
+
self.assertIsNone(code, kwargs)
|
|
256
|
+
self.assertNotIn("ntu_cool_materials", [c[1] for c in cmds], kwargs)
|
|
257
|
+
|
|
258
|
+
|
|
212
259
|
class ResolveYtDlpTests(unittest.TestCase):
|
|
213
260
|
def test_finds_launcher_in_scripts_dir_when_not_on_path(self) -> None:
|
|
214
261
|
import os
|
|
File without changes
|
{get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/requires.txt
RENAMED
|
File without changes
|
{get_class_material-1.0.2 → get_class_material-1.0.3}/get_class_material.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{get_class_material-1.0.2 → get_class_material-1.0.3}/ntu_cool_materials/spreadsheet_convert.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|