Run decode autoresearch on a local file or URL (host-only mode). Args: decode_path: Local file path or URL to a media file. Returns: Exit code (0 = success, 1 = failure).
(decode_path: str)
| 266 | |
| 267 | |
| 268 | async def run_decode_autoresearch(decode_path: str) -> int: |
| 269 | """Run decode autoresearch on a local file or URL (host-only mode). |
| 270 | |
| 271 | Args: |
| 272 | decode_path: Local file path or URL to a media file. |
| 273 | |
| 274 | Returns: |
| 275 | Exit code (0 = success, 1 = failure). |
| 276 | """ |
| 277 | print() |
| 278 | print("=" * 60) |
| 279 | print("DECODE AUTORESEARCH MODE") |
| 280 | print("=" * 60) |
| 281 | print() |
| 282 | |
| 283 | temp_download: str | None = None |
| 284 | |
| 285 | try: |
| 286 | # Resolve the file |
| 287 | resolved = _resolve_file(decode_path) |
| 288 | file_path = resolved.file_path |
| 289 | ext = resolved.extension |
| 290 | temp_download = resolved.temp_download_path |
| 291 | |
| 292 | # Validate extension |
| 293 | if ext not in SUPPORTED_EXTENSIONS: |
| 294 | supported = ", ".join(sorted(SUPPORTED_EXTENSIONS.keys())) |
| 295 | print( |
| 296 | f"{Fore.RED}Error: Unsupported file extension '{ext}'{Style.RESET_ALL}" |
| 297 | ) |
| 298 | print(f" Supported: {supported}") |
| 299 | return 1 |
| 300 | |
| 301 | # Validate file exists |
| 302 | if not os.path.isfile(file_path): |
| 303 | print(f"{Fore.RED}Error: File not found: {file_path}{Style.RESET_ALL}") |
| 304 | return 1 |
| 305 | |
| 306 | codec_name = SUPPORTED_EXTENSIONS[ext] |
| 307 | file_size = os.path.getsize(file_path) |
| 308 | print(f" File: {file_path}") |
| 309 | print(f" Size: {file_size:,} bytes") |
| 310 | print(f" Codec: {codec_name}") |
| 311 | print() |
| 312 | |
| 313 | # Read file and base64-encode into JSON-RPC payload |
| 314 | with open(file_path, "rb") as f: |
| 315 | file_bytes = f.read() |
| 316 | |
| 317 | payload_json = _build_jsonrpc_payload(file_bytes, ext) |
| 318 | |
| 319 | # Write payload to well-known path (C++ test reads this by default) |
| 320 | project_root = Path(__file__).resolve().parent.parent |
| 321 | payload_file = project_root / PAYLOAD_PATH |
| 322 | payload_file.parent.mkdir(parents=True, exist_ok=True) |
| 323 | payload_file.write_text(payload_json, encoding="utf-8") |
| 324 | |
| 325 | b64_size = len(base64.b64encode(file_bytes)) |
no test coverage detected