"""HTTP helpers extracted from execution/api_client.py in CP-2 Phase 8.

Provides shared HTTP utilities used by VideoModelClient and any legacy
client paths still routed through the api_client stub.

Currently only `_download_video` is canonicalized here. Other helpers
(_sniff_image_mime, _to_bytes) remain local to their providers — they
have no external consumers as of CP-2 Phase 8 audit.
"""

import logging

logger = logging.getLogger(__name__)


def _download_video(url: str, timeout: int = 60) -> bytes | None:
    """Download video bytes from a URL. Returns None on failure."""
    import urllib.request
    try:
        with urllib.request.urlopen(url, timeout=timeout) as resp:
            return resp.read()
    except Exception as e:
        logger.warning("Video download failed from %s: %s", url[:80], e)
        return None
