# Toolzu Timestamp Handling

## Configuration

**Check Frequency**: Every 4 hours (configurable in settings.json)
**Posts Checked**: 15 most recent posts (more than enough for frequent checks)
**Why 15?** Most accounts post 1-5 times per day, so checking 15 recent posts catches everything

## The Problem

**Toolzu does NOT provide actual post dates**. The website only shows thumbnails with download links - there's no date information anywhere on the page.

The `time=` parameter you see in thumbnail URLs is the **page load time**, not the post date. Using this would make all files show the same timestamp (when the page was loaded).

## The Solution: Quality Upgrade System

We use a two-step approach to get the best of both worlds:

### Step 1: Toolzu Download (High Resolution)
- Downloads files at 1920x1440 resolution
- Files initially get the current **download time** as timestamp
- This is just a placeholder - not the actual post date

### Step 2: Automatic Quality Upgrade (Accurate Timestamps)
- Automatically runs after Toolzu downloads complete
- Matches Toolzu files with FastDL files by Instagram media ID
- **For matched files:**
  - Uses Toolzu's high-resolution (1920x1440) file
  - Copies FastDL's accurate timestamp
  - Moves to final destination
- **For Toolzu-only files:**
  - Uses Toolzu file as-is with download time
  - Still better than nothing!

## Workflow Example

```
1. FastDL downloads 640x640 image with accurate date: 2025-09-22 14:27:13
2. Toolzu downloads 1920x1440 image with placeholder date: 2025-10-12 20:46:00
3. Quality upgrade merges them:
   - Uses 1920x1440 file from Toolzu
   - Sets timestamp to 2025-09-22 14:27:13 from FastDL
   - Moves to final destination

Result: High-resolution image with accurate date!
```

## Why This Works

- **FastDL**: Accurate timestamps, low resolution (640x640)
- **Toolzu**: High resolution (1920x1440), NO timestamps
- **Quality Upgrade**: Takes the best from both = High resolution + accurate dates

## Log Output

Before fix (WRONG - all same time):
```
✓ Saved: evalongoria_20251012_200000_18536798902006538.jpg (1920x1440, dated: 2025-10-12 20:00)
✓ Saved: evalongoria_20251012_200000_18536798920006538.jpg (1920x1440, dated: 2025-10-12 20:00)
```

After fix (CORRECT - uses download time, will be updated):
```
✓ Saved: evalongoria_20251012_204600_18536798902006538.jpg (1920x1440, will update timestamp from FastDL)
✓ Saved: evalongoria_20251012_204612_18536798920006538.jpg (1920x1440, will update timestamp from FastDL)
```

Then quality upgrade logs:
```
⬆️  Upgraded: evalongoria_20251012_204600_18536798902006538.jpg (1920x1440, dated: 2025-09-22 14:27)
⬆️  Upgraded: evalongoria_20251012_204612_18536798920006538.jpg (1920x1440, dated: 2025-09-22 14:28)
```

## Configuration

No configuration needed - quality upgrade is automatic!

Just enable both downloaders in `config/settings.json`:
```json
{
  "fastdl": {
    "enabled": true  // For accurate timestamps
  },
  "toolzu": {
    "enabled": true  // For high resolution
  }
}
```

## Technical Details

- Media ID matching: Both FastDL and Toolzu extract the same Instagram media IDs
- Pattern: `evalongoria_YYYYMMDD_HHMMSS_{MEDIA_ID}.jpg`
- Numeric IDs: 17-19 digits (e.g., `18536798902006538`)
- Video IDs: Alphanumeric (e.g., `AQNXzEzv7Y0V2xoe...`)
- Both formats are handled by the quality upgrade system
