Metadata-Version: 2.4
Name: metuclass
Version: 0.2.0
Summary: CLI tool to sync ODTUClass (METU Moodle) course files to local disk
Project-URL: Homepage, https://github.com/rusenbb/metu-class-auto
Project-URL: Repository, https://github.com/rusenbb/metu-class-auto
Project-URL: Issues, https://github.com/rusenbb/metu-class-auto/issues
Author-email: Rusen Birben <e279091@metu.edu.tr>
License-Expression: MIT
License-File: LICENSE
Keywords: lms,metu,metuclass,moodle,odtuclass,sync
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Education
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Description-Content-Type: text/markdown

# metuclass

CLI tool to sync [ODTUClass](https://odtuclass.metu.edu.tr) course files to your local machine.

Downloads PDFs, slides, homeworks, and any other files from your enrolled courses. Tracks changes so subsequent syncs only download new or updated files.

## Install

```bash
pip install metuclass
```

Requires Python 3.11+.

## Quick start

```bash
# Log in with your METU credentials
metuclass login

# See your courses
metuclass courses

# Download everything
metuclass sync
```

Files are saved to `~/metuclass/` by default, organized by course and section:

```
~/metuclass/
  CENG 334 Section 1/
    Week 01 - Introduction/
      slides.pdf
    Week 02 - Processes/
      slides.pdf
      notes.pdf
  CENG 596 Section 1/
    General/
      syllabus.pdf
    ...
```

## Commands

### `metuclass login`

Authenticate with your METU username and password. Stores a session token locally — you only need to do this once (or again if your password changes).

```bash
metuclass login
```

### `metuclass courses`

List all your enrolled courses.

```bash
metuclass courses
```

### `metuclass ls <course>`

Show files available in a course. You can use the course shortname or ID.

```bash
metuclass ls "CENG 334 Section 1"
metuclass ls 3100
```

### `metuclass sync [course]`

Download new and updated files. Omit the course to sync all courses.

```bash
# Sync a specific course
metuclass sync "CENG 334 Section 1"

# Sync all courses
metuclass sync

# Preview what would be downloaded
metuclass sync --dry-run

# Overwrite locally modified files
metuclass sync --force

# Download to a specific directory
metuclass sync --sync-dir ~/Documents/courses
```

### `metuclass config [key] [value]`

View or change configuration.

```bash
# Show all config
metuclass config

# Set sync directory
metuclass config sync.directory ~/Documents/courses
```

## Configuration

Config is stored at `~/.config/metuclass/config.toml`.

### Sync directory

Where files are downloaded to (default: `~/metuclass`). Set it with any of these (highest priority first):

1. `--sync-dir` flag
2. `METUCLASS_SYNC_DIR` environment variable
3. `metuclass config sync.directory <path>`

### Environment variables

You can set these in a `.env` file (in your working directory or `~/.config/metuclass/.env`):

```bash
METUCLASS_USERNAME=e123456
METUCLASS_PASSWORD=your_password
METUCLASS_SYNC_DIR=~/metuclass
```

When `METUCLASS_USERNAME` and `METUCLASS_PASSWORD` are set, `metuclass login` won't prompt for input — useful for automation.

## How sync works

1. Fetches the file list from ODTUClass for each course
2. Compares against a local manifest (SQLite database) to find new/updated files
3. Downloads changes concurrently, writing to temp files and renaming on success
4. Files with local modifications are skipped as conflicts (use `--force` to overwrite)

Running `metuclass sync` a second time is a no-op if nothing changed on ODTUClass.

## License

MIT
