mkv2cast.cli

Command-line interface for mkv2cast.

This is the main entry point for the application.

Functions

auto_detect_workers(backend)

Auto-detect optimal worker counts based on backend and system resources.

check_requirements()

Check system requirements.

cleanup_all_users_logs(days[, verbose])

Clean logs for all users (requires root).

cleanup_all_users_tmp([max_age_hours, verbose])

Clean tmp files for all users (requires root).

collect_targets(root, single, cfg)

Collect target files for processing.

get_all_users_mkv2cast_dirs()

Get mkv2cast directories for all users on the system.

get_gpu_info()

Detect GPU type and VRAM.

get_log_path(inp)

Generate log path for input file.

get_tmp_path(inp, worker_id, tag, cfg)

Generate temp path for encoding.

get_total_ram_gb()

Get total RAM in GB.

handle_utility_commands(cfg, args)

Handle utility commands that exit immediately.

is_our_output_or_tmp(name, cfg)

Check if filename is our output or temp file.

is_running_as_root()

Check if script is running as root.

main()

Main entry point.

main_json_progress(single, cfg)

JSON progress output mode for integration with external tools.

main_legacy(single, cfg)

Legacy sequential mode.

main_pipeline(single, cfg)

Pipeline mode with parallel workers.

main_rich(single, cfg)

Rich UI sequential mode.

output_exists_for_input(inp, cfg)

Check if output already exists for input file.

parse_args([args])

Parse command-line arguments and return config + optional file path.

register_process(proc)

Register a process for tracking.

run_watch_mode(single, cfg, interval)

Run in watch mode, monitoring directory for new MKV files.

should_process_file(filepath, cfg)

Check if file should be processed based on filters.

terminate_all_processes()

Terminate all active processes and wait for cleanup.

unregister_process(proc)

Unregister a process from tracking.

mkv2cast.cli.register_process(proc: Popen) None[source]

Register a process for tracking.

mkv2cast.cli.unregister_process(proc: Popen) None[source]

Unregister a process from tracking.

mkv2cast.cli.terminate_all_processes() None[source]

Terminate all active processes and wait for cleanup.

mkv2cast.cli.parse_args(args: List[str] | None = None) Tuple[Config, Path | None][source]

Parse command-line arguments and return config + optional file path.

mkv2cast.cli.is_our_output_or_tmp(name: str, cfg: Config) bool[source]

Check if filename is our output or temp file.

mkv2cast.cli.should_process_file(filepath: Path, cfg: Config) Tuple[bool, str | None][source]

Check if file should be processed based on filters.

mkv2cast.cli.output_exists_for_input(inp: Path, cfg: Config) bool[source]

Check if output already exists for input file.

mkv2cast.cli.collect_targets(root: Path, single: Path | None, cfg: Config) Tuple[List[Path], List[Tuple[Path, str]]][source]

Collect target files for processing.

mkv2cast.cli.is_running_as_root() bool[source]

Check if script is running as root.

mkv2cast.cli.get_total_ram_gb() int[source]

Get total RAM in GB.

mkv2cast.cli.get_gpu_info() Tuple[str, int][source]

Detect GPU type and VRAM. Returns: (gpu_type, vram_mb) gpu_type: “nvidia”, “amd”, “intel”, “unknown”

mkv2cast.cli.auto_detect_workers(backend: str) Tuple[int, int][source]

Auto-detect optimal worker counts based on backend and system resources. Returns: (encode_workers, integrity_workers)

mkv2cast.cli.get_all_users_mkv2cast_dirs() List[Dict[str, Any]][source]

Get mkv2cast directories for all users on the system. Only returns users that have mkv2cast data directories.

mkv2cast.cli.cleanup_all_users_logs(days: int, verbose: bool = True) Dict[str, int][source]

Clean logs for all users (requires root). Returns dict of {username: removed_count}.

mkv2cast.cli.cleanup_all_users_tmp(max_age_hours: int = 0, verbose: bool = True) Dict[str, int][source]

Clean tmp files for all users (requires root). max_age_hours=0 means clean all tmp files. Returns dict of {username: removed_count}.

mkv2cast.cli.get_log_path(inp: Path) Path[source]

Generate log path for input file.

mkv2cast.cli.get_tmp_path(inp: Path, worker_id: int, tag: str, cfg: Config) Path[source]

Generate temp path for encoding.

mkv2cast.cli.check_requirements() int[source]

Check system requirements.

mkv2cast.cli.handle_utility_commands(cfg: Config, args: Namespace) int | None[source]

Handle utility commands that exit immediately.

mkv2cast.cli.main_json_progress(single: Path | None, cfg: Config) Tuple[int, int, int, int, bool][source]

JSON progress output mode for integration with external tools.

Outputs structured JSON to stdout for each progress update.

mkv2cast.cli.main_legacy(single: Path | None, cfg: Config) Tuple[int, int, int, int, bool][source]

Legacy sequential mode. Returns (ok, skipped, failed, interrupted, was_interrupted).

mkv2cast.cli.main_rich(single: Path | None, cfg: Config) Tuple[int, int, int, int, bool][source]

Rich UI sequential mode. Returns (ok, skipped, failed, interrupted, was_interrupted).

mkv2cast.cli.main_pipeline(single: Path | None, cfg: Config) Tuple[int, int, int, int, bool][source]

Pipeline mode with parallel workers. Returns (ok, skipped, failed, interrupted_count, was_interrupted).

mkv2cast.cli.run_watch_mode(single: Path | None, cfg: Config, interval: float) int[source]

Run in watch mode, monitoring directory for new MKV files.

mkv2cast.cli.main() int[source]

Main entry point.