mkv2cast.history

History database for mkv2cast conversions.

Tracks all conversions with timestamps, durations, and results. Uses SQLite as primary storage with JSONL fallback if SQLite is unavailable.

Classes

HistoryDB(state_dir)

History storage with SQLite primary and JSONL text fallback.

HistoryRecorder(history_db, backend)

Track in-flight conversions and safely persist history updates.

class mkv2cast.history.HistoryDB(state_dir: Path)[source]

Bases: object

History storage with SQLite primary and JSONL text fallback.

record_start(input_path: Path, backend: str, input_size: int = 0) int[source]

Record conversion start, return entry ID.

record_finish(entry_id: int, output_path: Path | None, status: str, encode_time: float = 0, integrity_time: float = 0, output_size: int = 0, duration_ms: int = 0, error_msg: str | None = None) None[source]

Update entry with completion info.

record_skip(input_path: Path, reason: str, backend: str) None[source]

Record a skipped file.

get_recent(limit: int = 20) List[dict][source]

Get recent conversions.

get_stats() dict[source]

Get conversion statistics.

clean_old(days: int) int[source]

Remove entries older than N days. Returns count removed.

class mkv2cast.history.HistoryRecorder(history_db: HistoryDB | None, backend: str)[source]

Bases: object

Track in-flight conversions and safely persist history updates.

start(input_path: Path, input_size: int = 0) int[source]

Record a conversion start and track it for later completion.

finish(input_path: Path, status: str, output_path: Path | None = None, encode_time: float = 0, integrity_time: float = 0, output_size: int = 0, duration_ms: int = 0, error_msg: str | None = None) None[source]

Record completion for a tracked conversion.

skip(input_path: Path, reason: str) None[source]

Record a skipped file without a prior start entry.

interrupt_all(reason: str = 'interrupted') None[source]

Mark any active conversions as interrupted.