- Add GetToken() as unified auth entry point with method selection - Prompt [1] OAuth / [2] API token on first launch, save choice - Validate API tokens against /api/v1/users/self before saving - Check saved API token validity on reuse; fallback to re-prompt on failure - Add HTTP status check to GetCourseInfo and GetEnrolledCourses - Remove --api flag, auth method is now persistent and interactive
81 lines
2.5 KiB
Markdown
81 lines
2.5 KiB
Markdown
# Canvas Archiver
|
|
|
|
A command-line tool to archive Canvas LMS course content, including files, modules, and Panopto video recordings.
|
|
|
|
## Prerequisites
|
|
|
|
- Go 1.21 or higher
|
|
- [yt-dlp](https://github.com/yt-dlp/yt-dlp) installed and in PATH
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
git clone git.directme.in/Joren/CanvasArchiver
|
|
cd CanvasArchiver
|
|
go build -o canvasarchiver ./cmd/canvasarchiver
|
|
```
|
|
|
|
## Usage
|
|
1. Run the archiver:
|
|
```bash
|
|
./canvasarchiver
|
|
```
|
|
|
|
Or for files-only mode (all files flat, no videos):
|
|
```bash
|
|
./canvasarchiver -fo
|
|
```
|
|
|
|
Or for videos-only mode (all Panopto videos flat, no files):
|
|
```bash
|
|
./canvasarchiver -vo
|
|
```
|
|
|
|
2. On first run, you'll be prompted to choose an authentication method:
|
|
- **[1] Login via browser (OAuth)**: Visit the provided URL, authorize, and paste the code
|
|
- **[2] Use Canvas API token**: Enter a manually generated API token (e.g. `12230~...`)
|
|
|
|
The choice is saved and reused on subsequent runs.
|
|
|
|
3. Enter your Course ID when prompted (or use `-me` to download all enrolled courses)
|
|
|
|
4. The tool will download:
|
|
- Regular course files (to `Course Files/`)
|
|
- Module content (to `Modules/`)
|
|
- Panopto recordings (to `Recordings/`)
|
|
|
|
In `-vo` mode, only videos are downloaded — all into the course root directory (no subdirectories).
|
|
|
|
### Flags
|
|
|
|
| Flag | Description |
|
|
|------|-------------|
|
|
| `-fo` | Files only — download all files flat into one directory; skips videos and module structure |
|
|
| `-vo` | Videos only — scan recordings and all module video items, download everything flat into one directory; skips regular files |
|
|
| `-me` | Download all enrolled courses |
|
|
| `-n` | Prefix modules with order numbers `[1]`, `[2]`, etc. |
|
|
|
|
## Configuration
|
|
|
|
The following constants can be modified in `internal/config/config.go`:
|
|
|
|
- `BaseURL`: Canvas instance URL
|
|
- `ClientID`: OAuth client ID
|
|
- `ClientSecret`: OAuth client secret
|
|
- `PanoptoID`: Panopto external tool ID
|
|
|
|
## Authentication
|
|
|
|
Credentials are stored in `credentials.json` after the first successful authentication. The chosen method is remembered for subsequent runs — OAuth refresh tokens are automatically refreshed, and API tokens are validated before saving.
|
|
|
|
## Notes
|
|
|
|
- Files are organized to match Canvas structure
|
|
- SubHeaders in modules create nested folder structures
|
|
- Videos are downloaded with their original titles
|
|
- Existing files are skipped to avoid re-downloading
|
|
|
|
## License
|
|
|
|
This project is for educational purposes. Ensure you have permission to download course content.
|