A CLI tool to fix Trakt.tv watch history entries with incorrect dates. It changes entries watched before a specified cutoff date to "unknown" (no specific watched date).
Trakt didn't always have the option to mark entries as watched with an "unknown" date. Back then, many users (myself included) entered watch history using placeholder dates like release dates or arbitrary past dates. Now that Trakt supports "unknown" as a watched date option, this tool lets you bulk-fix those old entries.
It automates the process by:
- Finding all movies and episodes watched before your cutoff date
- Removing those entries from your history
- Re-adding them with an "unknown" watched date
- Bun v1.0 or later
- A Trakt.tv account
- Trakt API credentials
git clone https://github.com/alysson-souza/trakt-fixer.git
cd trakt-fixer
bun install- Go to Trakt API Applications
- Fill in the application details:
- Name: trakt-timefix (or whatever you prefer)
- Redirect URI:
urn:ietf:wg:oauth:2.0:oob
- Save and note your Client ID and Client Secret
# bash/zsh
export TRAKT_CLIENT_ID="your_client_id"
export TRAKT_CLIENT_SECRET="your_client_secret"
# fish
set -x TRAKT_CLIENT_ID "your_client_id"
set -x TRAKT_CLIENT_SECRET "your_client_secret"Or create a .env file (Bun loads it automatically):
TRAKT_CLIENT_ID=your_client_id
TRAKT_CLIENT_SECRET=your_client_secretbun start -- --cutoff <date> [options]| Option | Description |
|---|---|
--cutoff <date> |
Entries watched before this date will be fixed (ISO format: 2020-01-01). Defaults to Trakt join date |
--dry-run |
Preview changes without modifying anything |
--no-backup |
Skip backup creation |
--no-cache |
Force fresh fetch, ignore cached data |
-h, --help |
Show help message |
Preview what would be changed:
bun start -- --cutoff 2015-01-01 --dry-runFix all entries before 2015:
bun start -- --cutoff 2015-01-01Force fresh data fetch:
bun start -- --cutoff 2015-01-01 --no-cacheUse your Trakt join date as cutoff (auto-detected):
bun start -- --dry-runIf you need to undo changes and restore original watched dates:
# List available backups
bun run undo -- --list
# Restore from most recent backup
bun run undo
# Preview restoration without making changes
bun run undo -- --dry-run
# Restore from a specific backup file
bun run undo -- --backup ~/.config/trakt-timefix/backup-2024-01-15T10-30-00.jsonOn first run (or when tokens expire), you'll be prompted to authenticate:
- The tool will display a URL and a code
- Visit the URL in your browser
- Enter the code and authorize the application
- The tool will automatically continue once authorized
Tokens are stored locally and refreshed automatically when needed.
Data is stored in a platform-specific config directory:
| Platform | Location |
|---|---|
| Linux | ~/.config/trakt-timefix/ |
| macOS | ~/Library/Application Support/trakt-timefix/ |
| Windows | %APPDATA%\trakt-timefix\ |
On Linux and macOS, XDG_CONFIG_HOME is respected if set.
Files stored:
| File | Description |
|---|---|
tokens.json |
OAuth tokens (auto-refreshed) |
cache.json |
Cached history data (1h TTL, auto-refreshed) |
backup-*.json |
Backups of modified entries |
- Dry run mode: Preview changes before applying
- Automatic backups: Entries are backed up before modification
- Confirmation prompt: Asked before making changes
- Caching: Reduces API calls and allows quick re-runs
- Rate limit handling: Respects Trakt API limits with automatic retries
# Run tests
bun test
# Run tests in watch mode
bun test --watch
# Lint code
bun run lint
# Format code
bun run formatMIT