Commit Graph

134 Commits

Author SHA1 Message Date
felixfoertsch 686434f5c3 remove jellyfin, mqtt, webhook services, fix tests, add schema migrations
- delete server/services/jellyfin.ts, webhook.ts, mqtt.ts and their tests
- strip jellyfin/mqtt imports and startup calls from index.tsx and settings.ts
- remove /jellyfin, /mqtt, /mqtt/status, /mqtt/test, /jellyfin/webhook-plugin endpoints from settings router
- clean ENV_MAP and isEnvConfigured of jellyfin/mqtt keys
- add db/index.ts migrations for series_key, duration_seconds, scan_status, scan_error, last_scanned_at (new columns absent on older dev DBs)
- move idx_media_items_series_key out of SCHEMA into migrate() so it runs after the column is added
- fix all test fixtures: drop jellyfin_id/series_jellyfin_id column refs, update MediaItem/MediaStream object literals to match current types

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:54 +02:00
felixfoertsch 5bea914b14 review.ts: replace jellyfin_id/series_jellyfin_id with file_path/series_key, remove jellyfin imports
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-21 06:31:54 +02:00
felixfoertsch 6022ed09b2 simplify language-resolver: drop jellyfin resolveSeriesTvdb callback
remove resolveSeriesTvdb from LanguageResolverConfig, rename jellyfinFallback
to probeFallback, replace Jellyfin-based TVDB resolution with series_name
title search over Sonarr library, update tests accordingly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:54 +02:00
felixfoertsch 8a95026728 rewrite scan: filesystem walk + ffprobe, no jellyfin
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:21 +02:00
felixfoertsch fbfd492e18 rewrite rescan: upsertScannedItem from probe data, no jellyfin
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:21 +02:00
felixfoertsch 9b04ed87d2 new schema: drop jellyfin columns, file_path as unique key
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:21 +02:00
felixfoertsch 444d2eb733 extract normalizeLanguage, guessOriginalLanguage to language-utils.ts
Move language normalization out of jellyfin.ts into its own module so
non-Jellyfin services (ffmpeg, radarr, sonarr, analyzer) no longer
depend on the Jellyfin service file. jellyfin.ts re-exports
normalizeLanguage for backward compatibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:21 +02:00
felixfoertsch 7cb2714793 add discover.ts: recursive video file discovery with Bun.Glob, unit tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:21 +02:00
felixfoertsch 7d12241ccb add probe.ts: ffprobe JSON parser with probeFile, parseProbeOutput, unit tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:21 +02:00
felixfoertsch 96bf208a16 add path-parser: extract movie/episode metadata from Radarr/Sonarr file paths
Parses title, year, provider IDs (imdb/tmdb/tvdb), season, episode number,
and container from on-disk paths without requiring Jellyfin.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 06:31:21 +02:00
felixfoertsch 4fe651f822 add sonarr title fallback for episode language resolution, bump version
Build and Push Docker Image / build (push) Successful in 2m34s
2026-04-20 21:12:14 +02:00
felixfoertsch 65acc683b9 stop button aborts queue loop, remaining jobs stay pending in queue
Build and Push Docker Image / build (push) Successful in 6m48s
previously stop only killed the running ffmpeg process — the loop
immediately picked up the next pending job. now the abort signal
breaks the loop between jobs, so remaining items stay in the queue
column as pending jobs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 15:46:31 +02:00
felixfoertsch 1e749e0188 OG quality check compares against all non-OG streams in file, not just kept
Build and Push Docker Image / build (push) Successful in 3m55s
the Dead Zone case: OG is Japanese mono, English 5.1 exists but is removed
by config (audio_languages=[]). the previous check only looked at kept
streams, so it never fired. now compares OG channels against all non-OG
audio in the file — if a superior dub exists, flag for review regardless
of whether it's currently configured to be kept.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 14:00:10 +02:00
felixfoertsch fd1fb8c77b unify all back-to-inbox actions via shared sendToInbox logic
Build and Push Docker Image / build (push) Successful in 1m18s
every "← Back to inbox" button (review, queue, done, per-item unapprove,
per-item reopen) now does the same thing: reset plan to pending/unsorted,
clear auto_class, delete non-running jobs. previously unapprove left
sorted=1 (sent to review instead of inbox) and each column had its own
SQL. now consistent: back to inbox always means "needs re-processing."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 12:03:39 +02:00
felixfoertsch c3ee64974c flag OG quality inferior to non-OG as auto_heuristic (needs review)
Build and Push Docker Image / build (push) Successful in 59s
when the original language track has fewer channels than a kept non-OG
track (e.g. Japanese mono vs English 5.1), classify as auto_heuristic
instead of auto so the user can decide whether to prefer the dub.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 11:36:35 +02:00
felixfoertsch 3341ceed14 remove analyzer from scan, scan is now pure jellyfin ingest
Build and Push Docker Image / build (push) Successful in 1m13s
upsertJellyfinItem no longer runs analyzeItem or creates stream_decisions.
it inserts a minimal review_plans stub (pending, unsorted). all analysis
happens in processInbox. this means after scan, ALL items land in the
inbox — the "needs action" count equals the inbox count until processing
classifies them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 11:31:30 +02:00
felixfoertsch b7f6144a6a live pipeline updates during scan via SSE pipeline_changed events
Build and Push Docker Image / build (push) Successful in 38s
scan emits pipeline_changed every 25 items, rescan endpoints emit on
completion. pipeline page listens and throttle-reloads all column data
(1s debounce) so inbox fills progressively without manual navigation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 10:57:01 +02:00
felixfoertsch 2701441a1c background processing with stop, simplify pipeline header stats, remove inbox skip
Build and Push Docker Image / build (push) Successful in 1m40s
- processInbox runs in background, returns immediately, items appear in
  columns progressively via SSE-triggered reloads
- stop button aborts mid-run, processed items stay in their destination
- fix language resolver: resolve series TVDB before sonarrLang HTTP fallback
- remove skip/skip-all from inbox (not meaningful in process-based flow)
- pipeline header shows only: total, needs action, queued, errors
- fix column header height jitter with fixed subtitle slot height

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 10:06:44 +02:00
felixfoertsch 43d934ff68 background processing with stop, remove inbox skip, progressive column updates, fix header height
processing runs in background, items appear in columns progressively via
SSE-triggered reloads. stop button aborts mid-run, remaining items stay in
inbox. remove skip/skip-all from inbox. fix column header height jitter by
giving subtitle slot a fixed height.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 09:52:58 +02:00
felixfoertsch aafe5b2ec1 fix processInbox slowness: resolve series TVDB before sonarrLang HTTP fallback
Build and Push Docker Image / build (push) Successful in 1m9s
the resolver was calling sonarrLang with episode-level TVDB IDs first,
missing the library, triggering an HTTP round-trip per episode. now checks
the library and resolves the correct series TVDB before calling sonarrLang.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 09:38:04 +02:00
felixfoertsch 5aa8041f52 remove done column 50-item cap, rename Auto Review to Process Inbox, fix duplicate navigate
Build and Push Docker Image / build (push) Successful in 3m18s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 09:14:48 +02:00
felixfoertsch ffa6d95d6f rescan endpoints: reset to inbox, add series/season rescan
- Per-item rescan now resets plan to inbox (sorted=0, auto_class=NULL),
  clears external_raw, deletes pending jobs, then lets processInbox
  handle language resolution + analysis when auto_processing is on
- Add getSeriesEpisodes() to jellyfin service for bulk episode discovery
- Add POST /api/review/rescan-series endpoint accepting seriesJellyfinId
  + optional seasonNumber — discovers new episodes, resets all matching
  items to inbox, refreshes streams from Jellyfin, auto-processes if on

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 09:09:26 +02:00
felixfoertsch babc6414e5 processInbox auto-loads sonarr/radarr libraries when no external config provided
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 09:06:47 +02:00
felixfoertsch 648a17b763 rename sortInbox to processInbox, integrate language resolution into process step
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 09:04:18 +02:00
felixfoertsch ed085a5e17 add resolveLanguage module for standalone Sonarr/Radarr language resolution
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 08:58:25 +02:00
felixfoertsch 94610d05b7 strip Sonarr/Radarr lookups from scan path, make upsertJellyfinItem Jellyfin-only
RescanConfig now only carries audioLanguages. Radarr/Sonarr library
loading, language resolution, and resolveSeriesTvdb callback removed
from rescan.ts, scan.ts, and webhook.ts. RescanResult no longer tracks
radarrHit/sonarrHit/missingProviderId counters. Tests updated: removed
authoritative-source and resolved-TVDB-enables-Sonarr tests (moving to
processInbox in a later task), added assertion that scan never sets
sonarr/radarr as language source.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 08:54:43 +02:00
felixfoertsch a1da644aa3 fix sonarr OG-language miss when Jellyfin omits SeriesProviderIds
Build and Push Docker Image / build (push) Successful in 3m49s
episodes without SeriesProviderIds.Tvdb (older Jellyfin, un-refreshed items)
fell back to the episode-level TVDB ID, which never matched Sonarr's
series-keyed library. add resolveSeriesTvdb callback that fetches the series
item from Jellyfin to get the correct series TVDB ID, with per-scan caching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 07:39:24 +02:00
felixfoertsch c1baf3e476 audio detail: delete-file + delete-and-refetch via Radarr/Sonarr
Build and Push Docker Image / build (push) Successful in 3m24s
escape hatch for items the audio pipeline can't usefully fix — e.g. a
release whose only audio track is English commentary and needs to be
purged so *arr can find a better one. two buttons on the audio detail
page:

  🗑 Delete file            — unlinks the file and drops our DB rows
                              (cascades streams, plans, decisions, jobs)
  🗑 Delete & refetch       — same, then asks Radarr/Sonarr to rescan
                              (to notice the deleted file) and trigger
                              an indexer search for a replacement

backend: POST /api/review/:id/delete { refetch }. the refetch step is
best-effort and its result ships under `refetch` on the response so the
UI can surface partial wins — file deleted + db clean even if Radarr
doesn't have the movie. helpers live on the existing *arr service
modules (triggerMovieRefetch, triggerEpisodeRefetch) and do the command
lookups + POST /api/v3/command calls themselves.

UI uses native confirm dialogs showing the file path. on success,
navigates back to /pipeline since the detail page points at a row that
no longer exists.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 00:21:46 +02:00
felixfoertsch ee9add076a collapse Library page into a compact Pipeline header
Build and Push Docker Image / build (push) Successful in 1m17s
the separate Library page was mostly duplicating what the pipeline
columns + the item detail page already show. move its two useful bits —
the stats row (total / scanned / needs action / no change / approved /
done / errors) and the scan control bar — into a compact two-row header
above the pipeline columns, drop the library items table entirely, and
redirect "/" to "/pipeline".

the scan SSE buffering logic moves verbatim into PipelineHeader.tsx so
the progress bar and the stats refresh on completion keep working. the
dead /api/scan/items endpoint and its parseScanItemsQuery +
buildScanItemsWhere helpers (plus their tests) go away with the UI;
/api/scan, /api/scan/start, /api/scan/stop, /api/scan/events stay.

nav loses "Library" — Pipeline is the only entry point now.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 00:16:21 +02:00
felixfoertsch 8112bfeb65 per-track language override on audio detail page
Build and Push Docker Image / build (push) Successful in 3m3s
adds stream_decisions.custom_language (ISO 639-2 code or null) so the
user can correct a mislabeled audio track — e.g. a Spanish dub tagged
"und" in the container — without going through Jellyfin. the override
wins over stream.language everywhere it matters: the analyzer reads it
for keep/remove decisions and track ordering, the ffmpeg command builder
writes it as both the language metadata tag and the harmonized track
title, and reanalyze preserves it across reruns and rescans.

on the audio detail page, each pending audio row swaps its language
cell for an inline <select> populated from LANG_NAMES. picking the raw
file language clears the override; anything else sets it and triggers a
server-side reanalyze so keep/remove + target_index update immediately.
a small ✎ hint marks overridden tracks. rebuilt commands tag the output
accordingly so Jellyfin reads the corrected language.

PATCH /api/review/:id/stream/:streamId/language validates the code
against LANG_NAMES (accepts ISO 639-1/2/2B aliases, rejects garbage)
and runs reanalyze inside.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 00:05:31 +02:00
felixfoertsch 05a1345750 rip subtitle manager → sibling project, keep extraction only
Build and Push Docker Image / build (push) Successful in 2m31s
subtitle management (list/detail pages, /api/subtitles, subtitle_files
table, SubtitleFile types, predictExtractedFiles, nav link) moved to a
new sibling project at ~/Developer/netfelix-subtitles-manager/ where
it'll be rebuilt standalone later. this project now owns audio fixing
+ subtitle extraction only.

extraction still runs end to end: analyzeItem still marks every subtitle
stream as "remove from container", buildExtractionOutputs still wires
the -map 0:s:N + sidecar outputs into the ffmpeg command, and execute.ts
still flips review_plans.subs_extracted so verify.ts can check desired
state — just derived from the streams directly instead of by writing a
row per file to the now-gone subtitle_files table.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 22:50:52 +02:00
felixfoertsch 0fd3624d9f pipeline: uniform column headers, auto-process queue toggle, reopen → inbox
Build and Push Docker Image / build (push) Successful in 4m3s
column headers are now a fixed three-row layout (title / subtitle / button
row). every column always reserves all three rows so headers line up
regardless of contents; actions render disabled when their column is
empty instead of disappearing, which keeps the header height stable as
state changes.

the processing column gets a new "Auto-process Queue" checkbox that
mirrors the inbox's "Auto-process Inbox" toggle. backend adds an
auto_process_queue config, a maybeStartQueueProcessor() helper, a
POST /api/settings/auto-process-queue endpoint, and a hook in
enqueueAudioJob so approvals drain the queue hands-off when the toggle
is on.

reopen-all and per-item reopen now send items to the Inbox (sorted=0)
instead of back to Review. the done column's label and tooltip become
"← Back to inbox" to match, and the clear button moves to the right
slot so the header pattern (left=backward, right=forward) stays
consistent across columns.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 21:57:13 +02:00
felixfoertsch a21bcefb54 stream auto review progress over SSE so large inboxes don't feel frozen
Build and Push Docker Image / build (push) Successful in 1m18s
sortInbox is now async, yields every 10 items, and emits inbox_sort_start
+ inbox_sort_progress via optional hooks. the pipeline route handler
wires those hooks to the existing job events stream and guards against
a second concurrent sort with a 409.

the inbox column swaps its Auto Review button for a live "Sorting N/T"
counter and progress bar while the sort is in flight; the auto-process
toggle hides to give the progress the full subtitle line. the previous
behaviour was a frozen button for the entire duration of the sort.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 20:56:51 +02:00
felixfoertsch 76a16ba84c reanalyze plans during auto review so config changes take effect
Build and Push Docker Image / build (push) Successful in 4m0s
sortInbox used to distribute plans by the auto_class and stream_decisions
captured at scan time, which meant toggling an audio_languages entry and
then running "back to inbox" + "auto review" re-queued the item with the
stale decisions. now sortInbox re-runs the analyzer per plan against the
current audio_languages before distributing, matching the user's mental
model that auto review = re-apply the rules.

reanalyze() takes audioLanguages explicitly so callers can pass it in
once and tests can drive it without reaching into the singleton db.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 20:38:14 +02:00
felixfoertsch 91d8ed67b8 fix authoritative language sources getting demoted to needs_review
Build and Push Docker Image / build (push) Successful in 2m22s
rescan flagged every item where radarr/sonarr disagreed with jellyfin's
audio-track guess as needs_review=1, but the analyzer's authoritativeOg
check demands needs_review=0 — so the very items we had an authoritative
answer for were the ones dumped into the "Needs decision" bucket. Lost
(german dubs first on most files, sonarr authoritatively english) was
the perfect worst case: nearly every episode misclassified as manual.

trust the authoritative source unconditionally and reset needs_review=0
when it fires, mismatch or not.
2026-04-19 15:20:18 +02:00
felixfoertsch 495a40a6c6 restructure pipeline column headers with backward/skip/forward slots, rename ready → auto-approve
Build and Push Docker Image / build (push) Successful in 1m52s
- columnshell: three-row header (title, subtitle, backward · skip · forward grid)
- inbox: auto-processing checkbox moves into subtitle, page top-right toggle removed
- review: add ← back to inbox, rename approve-all-ready to approve auto
- queue: clear button relabeled ← back to inbox (matches existing behaviour)
- done: add ← back to review (reopen-all), clear moves to middle skip slot
- seriescard: action row mirrors movie card, now at the top
-  ready badge →  auto-approve with tooltip, review subtitle uses "auto · need decisions"
- new endpoints: /api/review/unsort-all, /api/review/reopen-all (+ tests)
2026-04-19 13:16:29 +02:00
felixfoertsch 84e669922b clear queue → inbox, move pipeline card actions to the top
Build and Push Docker Image / build (push) Successful in 3m54s
- execute/clear now also resets sorted=0 so cleared items land back in the
  inbox where the distributor can re-classify them; previously they got
  stranded in Review with auto_class='auto', unreachable by both
  "Approve all ready" and "Auto Review"
- pipelinecard: action row moves to the top so Skip/Approve/Back-to-review
  sit in the same place regardless of card body height; title row follows;
  file info (copy/transcode reasons) gets a dedicated row with the
  ready/needs-decision badge pushed to the right
- tests: clearQueue preserves running/completed jobs, only pending plans
  flip back to sorted=0 pending

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 11:34:49 +02:00
felixfoertsch 0d560743f3 fix manual language overrides wiped on rescan, use series tvdb for sonarr, split seriescard controls
Build and Push Docker Image / build (push) Successful in 3m31s
- rescan: skip jellyfin/radarr/sonarr lookups when orig_lang_source='manual' so user pins survive webhook + full scans
- jellyfin: request SeriesProviderIds so episodes can resolve to the series-level tvdb id
- sonarr: drop the lookup[0] fallback that silently returned unrelated shows on tvdb misses
- seriescard: split badges+language and approve buttons onto separate rows; seasongroup header wraps with ml-auto so buttons don't overflow the narrow pipeline column
- tests: cover manual override preservation and episode → series tvdb resolution

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 07:41:08 +02:00
felixfoertsch b9b4a50e8a rescan: auto-sort inbox after scan when auto_processing is on
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 10:43:03 +02:00
felixfoertsch da5bd6cac2 settings: POST /auto-processing toggles flag and optionally drains inbox 2026-04-18 10:41:54 +02:00
felixfoertsch 75104402fa review: /pipeline payload adds inbox + ready/manual counts 2026-04-18 10:41:11 +02:00
felixfoertsch 43b190a1a0 sse: broadcast inbox_sorted on distributor runs
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 10:40:19 +02:00
felixfoertsch 6faa5986a3 review: add approveReady + POST /approve-ready endpoint
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 10:38:55 +02:00
felixfoertsch 114b6687c6 review: add sortInbox distributor + POST /sort-inbox endpoint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 10:36:05 +02:00
felixfoertsch 82c8c89fb9 review: buildReviewGroups accepts bucket param, sorts by auto_class
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 10:30:43 +02:00
felixfoertsch 67f1b9440e review: persist auto_class via reanalyze + rescan
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 10:24:22 +02:00
felixfoertsch 8e1deb39d5 analyzer tests: narrow orig_lang_source type to MediaItem union
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 10:20:22 +02:00
felixfoertsch 455796ebb6 analyzer: only count commentary-driven removes as heuristic
snapshot decisions after decideAction, before deduplicateAudioByLanguage;
diff to identify tracks that flipped keep→remove due to the commentary
regex — language-driven removes no longer falsely upgrade auto_class to
auto_heuristic even when the title coincidentally matches

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 10:19:22 +02:00
felixfoertsch c595ad3792 analyzer: classify each plan as auto/auto_heuristic/manual
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 10:15:01 +02:00
felixfoertsch ef417bea09 schema: add auto_class + sorted to review_plans, drop confidence
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 10:10:40 +02:00