Commit Graph

5 Commits

Author SHA1 Message Date
wmantly 51e6817393 Add exponential backoff retry to all downstream calls
New controller/retry.js wraps async calls with infinite retries, capped

at 30s with jitter. Applied to: TPB search, TMDB, Emby, Ollama chat,

Transmission RPC, and the status/status interval calls inherit it via

a Proxy around the Transmission client.

Also handles ollama package returning pre-parsed JSON objects.

Signed-off-by: William Mantly <wmantly@gmail.com>
2026-07-20 14:44:41 -04:00
wmantly bd9f058f26 Use official ollama npm client for all LLM calls
Replaces hand-rolled fetch to /api/chat with the ollama@0.6.3 package.

The package supplies proper Accept/Content-Type/User-Agent headers and

auto-handles the Ollama protocol, fixing the CDN 403s Node's bare fetch

gets against ollama.com during filing.

Both organize and search LLM ranking now route through controller/ollama.js.

Signed-off-by: William Mantly <wmantly@gmail.com>
2026-07-20 12:43:25 -04:00
wmantly 47a930eddb Add explicit User-Agent to Ollama API calls
Node's default fetch sends a bare User-Agent that Google's CDN

fronting ollama.com rejects with 403. curl worked because it

sends curl/. Fixes organize (and search LLM ranking).

Signed-off-by: William Mantly <wmantly@gmail.com>
2026-07-20 12:29:09 -04:00
wmantly 40a39b2d14 Add Ollama/organize logging to debug 403 filing failures
- Log raw Ollama HTTP body on non-2xx responses

- Log JSON extraction failures with raw content

- Log organizeWatcher tick errors instead of swallowing them

Signed-off-by: William Mantly <wmantly@gmail.com>
2026-07-20 11:55:41 -04:00
wmantly fd5ef14999 Harden auth, add AI smart-search and post-download organization
Security & correctness hardening:
- Gate /__api/token/auth behind auth and self-scope every handler to the
  caller (was fully unauthenticated — account-takeover hole).
- Escape LDAP filter values (injection) and reject empty-password binds.
- Enforce per-torrent ownership so private torrents aren't exposed via IDOR.
- Assorted cleanup: fix 'use static' typos, drop dead Torrent.migrate + the
  getTorrentData noUpdate flag, Buffer.alloc, __dirname-relative reads,
  res.statusCode in the error handler, const-scope pubsub.

Login-gated proxy + anti-indexing:
- Block all proxying for logged-out users via an auth-token cookie the front
  end mirrors from its token; serve a local login page instead of hitting TPB.
- robots.txt disallow-all + X-Robots-Tag noindex.

Torrent category:
- Store a normalized category (TV/Movie/Music/Adult/App/Game/Other) mapped
  from the TPB category id; captured at add time (migration).

Smart Search (movies/TV):
- New /__api/search: TMDB title confirm -> scrape piratebay.party HTML ->
  Ollama ranks releases against quality prefs (x265/1080p/~1.5GB/subs,
  prefer uncut) returning a recommended pick, optional warned 4K, and other
  editions. Front-end Smart Search box + dialog feeding the existing add flow.

Post-download organization -> Emby (public Movie/TV only):
- Completion watcher files finished torrents: Ollama parses the release name,
  TMDB canonicalizes title/year, files main video (+subs) into the library
  with edition/quality-aware names (movies + TV SxxExx), stops seeding, and
  triggers an Emby library scan. Low-confidence matches are flagged, not
  mis-filed; correctable via "Fix match". Adds organizedAt/metadata columns.

Shared helpers: controller/tmdb.js, controller/ollama.js. Config blocks for
tmdb/ollama/search/emby/library/organize (secrets stay in gitignored secrets.js).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 14:19:13 -04:00