Files

54 lines
1.4 KiB
Python

#!/usr/bin/env python3
"""
MISF VOB Download — production entry (PyInstaller / double-click).
Config, Input/, and Output/ live in the same folder as the .exe.
"""
from __future__ import annotations
import os
import sys
import traceback
from pathlib import Path
ROOT = Path(__file__).resolve().parent
SRC = ROOT / "src"
if not getattr(sys, "frozen", False) and str(SRC) not in sys.path:
sys.path.insert(0, str(SRC))
from planner_download import build_arg_parser, run_download_workflow # noqa: E402
def _run_workflow() -> int:
exit_code = 0
try:
args = build_arg_parser().parse_args()
run_download_workflow(
facility_limit=max(0, args.limit),
facility_name=args.facility.strip() or None,
resume=args.resume,
keep_browser=args.keep_browser,
screenshot_on_error=args.screenshot and not args.no_screenshot,
)
except KeyboardInterrupt:
print("\nCancelled by user.")
exit_code = 130
except SystemExit as exc:
exit_code = int(exc.code) if exc.code is not None else 0
except Exception:
traceback.print_exc()
exit_code = 1
return exit_code
def main() -> int:
if getattr(sys, "frozen", False):
from log_window import run_with_live_logs
return run_with_live_logs(_run_workflow)
return _run_workflow()
if __name__ == "__main__":
raise SystemExit(main())