fix(video-generation): validate provider download URLs (#8446)

* fix(video-generation): restrict provider download destinations

* docs(video-generation): clarify shared MiniMax download hosts
This commit is contained in:
Nan Gao 2026-11-21 10:52:07 +08:00 committed by GitHub
parent 6499631484
commit 7afb749992
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 289 additions and 37 deletions

View File

@ -160,6 +160,16 @@ accepts `MINIMAX_VIDEO_RESOLUTION` and `MINIMAX_VIDEO_DURATION` (integer seconds
Unset overrides use the provider defaults. Invalid duration strings fail before
the script submits a request.
Generated videos download over HTTPS on port 443. The skill checks the
provider's download-host allowlist before the first request and after each
redirect, up to five redirects. Gemini sends its API key only to its API host
and drops it when a download moves to storage. For a MiniMax deployment using
another CDN, set `MINIMAX_VIDEO_DOWNLOAD_HOSTS` in the runtime environment to
the comma-separated, exact DNS names of trusted file hosts. Each entry grants
download access to that entire host. If the custom API endpoint set in
`MINIMAX_API_HOST` also serves video files, include its hostname in
`MINIMAX_VIDEO_DOWNLOAD_HOSTS` as well.
The video-generation skill derives reference-image MIME metadata from `.png`,
`.jpg`, `.jpeg`, `.webp`, and `.gif` filename extensions (case-insensitive). A
submitted reference with a missing or unrecognized extension raises a clear error

View File

@ -171,6 +171,14 @@ MiniMax uses `MINIMAX_API_HOST` (default `https://api.minimaxi.com`) and
`MINIMAX_VIDEO_MODEL` (default `MiniMax-Hailuo-2.3`). It uses the first reference
image as `first_frame_image`.
The skill downloads video files from allowlisted HTTPS hosts on port 443.
MiniMax deployments using additional storage hosts can set
`MINIMAX_VIDEO_DOWNLOAD_HOSTS` to a comma-separated list of exact hostnames
approved by the operator. Configure these names in the deployment environment.
If one custom host serves both the MiniMax API and video files, set
`MINIMAX_API_HOST` to its URL and include its hostname in
`MINIMAX_VIDEO_DOWNLOAD_HOSTS`. Every redirect must also use an approved host.
Set `MINIMAX_VIDEO_RESOLUTION` and `MINIMAX_VIDEO_DURATION` (integer seconds) to
override the API defaults. With Hailuo 2.3, use `768P` at 6 or 10 seconds, or
`1080P` at 6 seconds. For a draft and final pass, start at `768P` and switch to

View File

@ -1,11 +1,24 @@
import base64
import os
import re
import sys
import time
from urllib.parse import urljoin, urlsplit
import requests
MINIMAX_DEFAULT_HOST = "https://api.minimaxi.com"
GEMINI_API_HOST = "generativelanguage.googleapis.com"
MINIMAX_VIDEO_HOSTS = {
"api.minimaxi.com",
"api.minimax.io",
"api.minimax.cn",
"filecdn.minimax.chat",
"cdn.hailuoai.video",
"video-product.cdn.minimax.io",
}
MINIMAX_OSS_ENDPOINTS = {"oss-cn-wulanchabu.aliyuncs.com", "oss-cn-shanghai.aliyuncs.com"}
MAX_DOWNLOAD_REDIRECTS = 5
def _resolve_provider(override_env: str, existing_provider: str, has_existing_creds: bool) -> str:
@ -37,6 +50,12 @@ def _check_base_resp(payload: dict) -> None:
raise Exception(f"MiniMax error {base.get('status_code')}: {base.get('status_msg')}")
def _require_success(response: requests.Response) -> None:
response.raise_for_status()
if not 200 <= response.status_code < 300:
raise ValueError(f"Unexpected HTTP status {response.status_code} from video provider")
def _guess_mime(image_path: str) -> str:
ext = os.path.splitext(image_path)[1].lower()
mime_types = {
@ -66,8 +85,9 @@ def _poll_video_task(host: str, auth: str, task_id: str, max_attempts: int = 120
headers={"Authorization": auth},
params={"task_id": task_id},
timeout=30,
allow_redirects=False,
)
response.raise_for_status()
_require_success(response)
payload = response.json()
status = payload.get("status")
if status == "Success":
@ -91,11 +111,12 @@ def _poll_gemini_operation(api_key: str, operation_name: str, max_attempts: int
"""
for _ in range(max_attempts):
response = requests.get(
f"https://generativelanguage.googleapis.com/v1beta/{operation_name}",
f"https://{GEMINI_API_HOST}/v1beta/{operation_name}",
headers={"x-goog-api-key": api_key},
timeout=30,
allow_redirects=False,
)
response.raise_for_status()
_require_success(response)
payload = response.json()
if not payload.get("done", False):
time.sleep(interval)
@ -123,19 +144,58 @@ def _retrieve_file_url(host: str, auth: str, file_id: str) -> str:
headers={"Authorization": auth},
params={"file_id": file_id},
timeout=30,
allow_redirects=False,
)
response.raise_for_status()
_require_success(response)
payload = response.json()
_check_base_resp(payload)
return payload["file"]["download_url"]
def _download(url: str, output_file: str) -> None:
response = requests.get(url, timeout=300)
response.raise_for_status()
_ensure_output_dir(output_file)
with open(output_file, "wb") as f:
f.write(response.content)
def _download_host(url: str, *, gemini: bool) -> str:
if not isinstance(url, str) or re.search(r"[\x00-\x20\x7f\\]", url):
raise ValueError("Invalid video download URL")
parsed = urlsplit(url)
host = parsed.hostname
if parsed.scheme != "https" or not host or parsed.netloc.lower() not in {host, f"{host}:443"}:
raise ValueError("Video downloads require an HTTPS host on port 443 without user information")
if not re.fullmatch(r"(?:[a-z0-9-]+\.)+[a-z][a-z0-9-]*", host):
raise ValueError("Invalid video download hostname")
# Only the storage provider controls DNS for bucket endpoints under these
# exact suffixes. A bucket name is one DNS label.
endpoint = host.partition(".")[2]
if gemini:
trusted = host in {GEMINI_API_HOST, "storage.googleapis.com"}
storage_endpoints = {"storage.googleapis.com"}
else:
extra_hosts = os.getenv("MINIMAX_VIDEO_DOWNLOAD_HOSTS", "").split(",")
trusted = host in MINIMAX_VIDEO_HOSTS or host in {name.strip().lower() for name in extra_hosts}
storage_endpoints = MINIMAX_OSS_ENDPOINTS
if trusted or endpoint in storage_endpoints:
return host
raise ValueError(f"Video download host {host!r} is outside the provider allowlist")
def _download(url: str, output_file: str, *, gemini_api_key: str = "") -> None:
headers = {"x-goog-api-key": gemini_api_key} if gemini_api_key else {}
for _ in range(MAX_DOWNLOAD_REDIRECTS + 1):
host = _download_host(url, gemini=bool(gemini_api_key))
if host != GEMINI_API_HOST:
headers = {}
response = requests.get(url, headers=headers, timeout=300, allow_redirects=False)
if response.status_code in {301, 302, 303, 307, 308}:
location = response.headers.get("Location")
if not location:
raise ValueError("Video download redirect has no destination")
url = urljoin(url, location)
continue
_require_success(response)
_ensure_output_dir(output_file)
with open(output_file, "wb") as f:
f.write(response.content)
return
raise ValueError("Too many video download redirects")
def _generate_video_minimax(prompt: str, reference_images: list[str], output_file: str) -> str:
@ -168,8 +228,9 @@ def _generate_video_minimax(prompt: str, reference_images: list[str], output_fil
headers={"Authorization": auth, "Content-Type": "application/json"},
json=body,
timeout=60,
allow_redirects=False,
)
response.raise_for_status()
_require_success(response)
payload = response.json()
_check_base_resp(payload)
task_id = payload["task_id"]
@ -183,11 +244,7 @@ def download(url: str, output_file: str) -> None:
gemini_api_key = os.getenv("GEMINI_API_KEY")
if not gemini_api_key:
raise ValueError("GEMINI_API_KEY is not set")
response = requests.get(url, headers={"x-goog-api-key": gemini_api_key}, timeout=300)
response.raise_for_status()
_ensure_output_dir(output_file)
with open(output_file, "wb") as f:
f.write(response.content)
_download(url, output_file, gemini_api_key=gemini_api_key)
def _generate_video_gemini(prompt: str, reference_images: list[str], output_file: str, aspect_ratio: str = "16:9") -> str:
@ -206,12 +263,13 @@ def _generate_video_gemini(prompt: str, reference_images: list[str], output_file
if not gemini_api_key:
raise ValueError("GEMINI_API_KEY is not set")
response = requests.post(
"https://generativelanguage.googleapis.com/v1beta/models/veo-3.1-generate-preview:predictLongRunning",
f"https://{GEMINI_API_HOST}/v1beta/models/veo-3.1-generate-preview:predictLongRunning",
headers={"x-goog-api-key": gemini_api_key, "Content-Type": "application/json"},
json=request_json,
timeout=60,
allow_redirects=False,
)
response.raise_for_status()
_require_success(response)
data = response.json()
operation_name = data["name"]
download_url = _poll_gemini_operation(gemini_api_key, operation_name)

View File

@ -8,6 +8,8 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
from skill_loader import FakeResp, load # noqa: E402
vid = load("video-generation")
GEMINI_VIDEO = "https://generativelanguage.googleapis.com/download/v1beta/files/video"
MINIMAX_VIDEO = "https://filecdn.minimax.chat/v.mp4"
@pytest.fixture(autouse=True)
@ -17,6 +19,7 @@ def clean_env(monkeypatch):
"MINIMAX_API_KEY",
"VIDEO_GENERATION_PROVIDER",
"MINIMAX_API_HOST",
"MINIMAX_VIDEO_DOWNLOAD_HOSTS",
"MINIMAX_VIDEO_MODEL",
"MINIMAX_VIDEO_RESOLUTION",
"MINIMAX_VIDEO_DURATION",
@ -62,10 +65,12 @@ def test_minimax_full_flow(monkeypatch, tmp_path, video_settings):
def fake_post(url, headers=None, json=None, **kw):
posts["url"] = url
posts["json"] = json
assert kw["allow_redirects"] is False
assert headers["Authorization"] == "Bearer m"
return FakeResp({"task_id": "T1", "base_resp": {"status_code": 0}})
def fake_get(url, headers=None, params=None, **kw):
assert kw["allow_redirects"] is False
if url.endswith("/v1/query/video_generation"):
assert headers["Authorization"] == "Bearer m"
assert params["task_id"] == "T1"
@ -74,9 +79,11 @@ def test_minimax_full_flow(monkeypatch, tmp_path, video_settings):
if url.endswith("/v1/files/retrieve"):
assert headers["Authorization"] == "Bearer m"
assert params["file_id"] == "F1"
return FakeResp({"file": {"download_url": "https://dl/v.mp4"},
return FakeResp({"file": {"download_url": MINIMAX_VIDEO},
"base_resp": {"status_code": 0}})
return FakeResp(content=b"MP4DATA") # the actual download
assert url == MINIMAX_VIDEO
assert not headers
return FakeResp(content=b"MP4DATA")
monkeypatch.setattr(vid.requests, "post", fake_post)
monkeypatch.setattr(vid.requests, "get", fake_get)
@ -124,7 +131,7 @@ def test_minimax_reference_first_frame(monkeypatch, tmp_path):
if url.endswith("/v1/query/video_generation"):
return FakeResp({"status": "Success", "file_id": "F1", "base_resp": {"status_code": 0}})
if url.endswith("/v1/files/retrieve"):
return FakeResp({"file": {"download_url": "https://dl/v.mp4"}, "base_resp": {"status_code": 0}})
return FakeResp({"file": {"download_url": MINIMAX_VIDEO}, "base_resp": {"status_code": 0}})
return FakeResp(content=b"X")
monkeypatch.setattr(vid.requests, "post", fake_post)
@ -194,24 +201,179 @@ def test_gemini_download_raises_on_http_error(monkeypatch, tmp_path):
monkeypatch.setattr(vid.requests, "get", fake_get)
out = tmp_path / "sub" / "v.mp4"
with pytest.raises(requests.HTTPError):
vid.download("https://dl/v.mp4", str(out))
vid.download(GEMINI_VIDEO, str(out))
assert calls["timeout"] # a timeout is now passed
assert not out.exists()
def test_gemini_download_writes_nested_dir(monkeypatch, tmp_path):
@pytest.mark.parametrize(
("url", "expected_headers"),
[(GEMINI_VIDEO, {"x-goog-api-key": "g"}), ("https://storage.googleapis.com:443/example/video.mp4", {})],
)
def test_gemini_download_writes_nested_dir(monkeypatch, tmp_path, url, expected_headers):
monkeypatch.setenv("GEMINI_API_KEY", "g")
def fake_get(url, headers=None, **kw):
assert headers["x-goog-api-key"] == "g"
assert (headers or {}) == expected_headers
return FakeResp(content=b"VIDEO")
monkeypatch.setattr(vid.requests, "get", fake_get)
out = tmp_path / "nested" / "dir" / "v.mp4"
vid.download("https://dl/v.mp4", str(out))
vid.download(url, str(out))
assert out.read_bytes() == b"VIDEO"
def redirect(location):
response = requests.Response()
response.status_code = 302
response.headers["Location"] = location
return response
@pytest.mark.parametrize("provider", ["gemini", "minimax"])
@pytest.mark.parametrize("via_redirect", [False, True], ids=["initial-url", "redirect"])
def test_generation_rejects_untrusted_download(monkeypatch, tmp_path, provider, via_redirect):
monkeypatch.setenv("VIDEO_GENERATION_PROVIDER", provider)
monkeypatch.setenv("GEMINI_API_KEY", "g")
monkeypatch.setenv("MINIMAX_API_KEY", "m")
untrusted = "https://untrusted.example/video"
allowed = GEMINI_VIDEO if provider == "gemini" else MINIMAX_VIDEO
resource_url = allowed if via_redirect else untrusted
downloads = []
def post(url, **kwargs):
assert kwargs["allow_redirects"] is False
return FakeResp({"name": "operations/test"} if provider == "gemini" else {"task_id": "T1"})
def get(url, **kwargs):
assert kwargs["allow_redirects"] is False
if url.endswith("/operations/test"):
samples = [{"video": {"uri": resource_url}}]
return FakeResp({"done": True, "response": {"generateVideoResponse": {"generatedSamples": samples}}})
if url.endswith("/query/video_generation"):
return FakeResp({"status": "Success", "file_id": "F1"})
if url.endswith("/files/retrieve"):
return FakeResp({"file": {"download_url": resource_url}})
assert url == allowed
downloads.append(url)
return redirect(untrusted)
monkeypatch.setattr(vid.requests, "post", post)
monkeypatch.setattr(vid.requests, "get", get)
prompt = tmp_path / "prompt.txt"
prompt.write_text("a cat runs")
output = tmp_path / "video.mp4"
output.write_bytes(b"existing video")
with pytest.raises(ValueError):
vid.generate_video(str(prompt), [], str(output))
assert downloads == ([allowed] if via_redirect else [])
assert output.read_bytes() == b"existing video"
@pytest.mark.parametrize(
("download", "url"),
[
(vid.download, "http://generativelanguage.googleapis.com/video"),
(vid.download, "https://user@storage.googleapis.com/video"),
(vid.download, "https://generativelanguage.googleapis.com:8443/video"),
(vid._download, "https://127.0.0.1/video"),
(vid._download, "https://filecdn.minimax.chat.example/video"),
(vid._download, "https://bucket.oss-cn-wulanchabu-internal.aliyuncs.com/video"),
],
)
def test_download_rejects_invalid_destination_before_transport(monkeypatch, tmp_path, download, url):
monkeypatch.setenv("GEMINI_API_KEY", "g")
monkeypatch.setattr(vid.requests, "get", lambda *a, **kw: pytest.fail("unexpected network request"))
output = tmp_path / "video.mp4"
with pytest.raises(ValueError):
download(url, str(output))
assert not output.exists()
@pytest.mark.parametrize(
("download", "start", "signed_url", "initial_headers"),
[
(vid.download, GEMINI_VIDEO, "https://storage.googleapis.com/example/v.mp4?signature=test", {"x-goog-api-key": "g"}),
(vid._download, MINIMAX_VIDEO, "https://bucket.oss-cn-wulanchabu.aliyuncs.com/v.mp4?signature=test", {}),
],
)
def test_download_checks_redirects_and_scopes_credentials(monkeypatch, tmp_path, download, start, signed_url, initial_headers):
monkeypatch.setenv("GEMINI_API_KEY", "g")
relative_target = start + "?step=1"
calls = []
responses = {start: redirect("?step=1"), relative_target: redirect(signed_url), signed_url: FakeResp(content=b"video")}
def get(url, *, headers=None, allow_redirects, **kwargs):
assert allow_redirects is False
calls.append((url, headers or {}))
return responses[url]
monkeypatch.setattr(vid.requests, "get", get)
output = tmp_path / "video.mp4"
download(start, str(output))
assert calls == [(start, initial_headers), (relative_target, initial_headers), (signed_url, {})]
assert output.read_bytes() == b"video"
def test_gemini_storage_redirect_cannot_reauthorize_download(monkeypatch, tmp_path):
monkeypatch.setenv("GEMINI_API_KEY", "g")
storage = "https://storage.googleapis.com/example/video"
calls = []
def get(url, *, headers, **kwargs):
calls.append((url, headers))
return redirect(GEMINI_VIDEO) if url == storage else FakeResp(content=b"video")
monkeypatch.setattr(vid.requests, "get", get)
vid.download(storage, str(tmp_path / "video.mp4"))
assert calls == [(storage, {}), (GEMINI_VIDEO, {})]
def test_minimax_custom_download_host_requires_exact_approval(monkeypatch, tmp_path):
monkeypatch.setenv("MINIMAX_API_HOST", "https://files.example.test")
monkeypatch.setenv("MINIMAX_VIDEO_DOWNLOAD_HOSTS", "*.example.test")
url = "https://files.example.test/video"
calls = []
def get(url, *, headers, **kwargs):
calls.append((url, headers))
return FakeResp(content=b"video")
monkeypatch.setattr(vid.requests, "get", get)
out = tmp_path / "video.mp4"
with pytest.raises(ValueError, match="outside the provider allowlist"):
vid._download(url, str(out))
assert calls == []
monkeypatch.setenv("MINIMAX_VIDEO_DOWNLOAD_HOSTS", "cdn.example.test, Files.Example.Test")
vid._download(url, str(out))
assert calls == [(url, {})]
assert out.read_bytes() == b"video"
@pytest.mark.parametrize("count", [5, 6])
def test_download_limits_redirects(monkeypatch, tmp_path, count):
calls = []
def get(url, **kwargs):
assert kwargs["allow_redirects"] is False
calls.append(url)
if len(calls) <= count:
return redirect(f"?hop={len(calls)}")
return FakeResp(content=b"video")
monkeypatch.setattr(vid.requests, "get", get)
output = tmp_path / "video.mp4"
if count == 5:
vid._download(MINIMAX_VIDEO, str(output))
assert output.read_bytes() == b"video"
else:
with pytest.raises(ValueError):
vid._download(MINIMAX_VIDEO, str(output))
assert not output.exists()
assert len(calls) == 6
def test_gemini_post_raises_on_http_error(monkeypatch, tmp_path):
monkeypatch.setenv("GEMINI_API_KEY", "g")
@ -225,6 +387,20 @@ def test_gemini_post_raises_on_http_error(monkeypatch, tmp_path):
vid.generate_video(str(pf), [], str(tmp_path / "v.mp4"), "16:9")
def test_gemini_poll_rejects_redirect_even_with_a_valid_response_body(monkeypatch):
def get(url, **kwargs):
assert url.endswith("/operations/test")
assert kwargs["allow_redirects"] is False
samples = [{"video": {"uri": GEMINI_VIDEO}}]
result = FakeResp({"done": True, "response": {"generateVideoResponse": {"generatedSamples": samples}}}, status_code=302)
result.headers = {"Location": "/operations/other"}
return result
monkeypatch.setattr(vid.requests, "get", get)
with pytest.raises(ValueError):
vid._poll_gemini_operation("g", "operations/test", max_attempts=1)
def test_gemini_poll_is_bounded(monkeypatch):
# The MiniMax path bounds its polling; the Gemini operation path must too.
polls = {"count": 0}
@ -322,26 +498,23 @@ def test_gemini_forwards_aspect_ratio_to_predict_request(monkeypatch, tmp_path):
def fake_get(url, headers=None, **kw):
assert headers["x-goog-api-key"] == "g"
if url == GEMINI_VIDEO:
return FakeResp(content=b"video")
return FakeResp(
json_data={
"done": True,
"response": {
"generateVideoResponse": {
"generatedSamples": [
{"video": {"uri": "https://example.test/v.mp4"}}
{"video": {"uri": GEMINI_VIDEO}}
]
}
},
},
)
def fake_download(uri, output_file):
with open(output_file, "wb") as f:
f.write(b"video")
monkeypatch.setattr(vid.requests, "post", fake_post)
monkeypatch.setattr(vid.requests, "get", fake_get)
monkeypatch.setattr(vid, "download", fake_download)
pf = tmp_path / "p.json"
pf.write_text("a tall cat", encoding="utf-8")

View File

@ -18,6 +18,7 @@ def clean_env(monkeypatch):
"GEMINI_API_KEY",
"MINIMAX_API_KEY",
"VIDEO_GENERATION_PROVIDER",
"MINIMAX_API_HOST",
"MINIMAX_VIDEO_RESOLUTION",
"MINIMAX_VIDEO_DURATION",
):
@ -63,6 +64,7 @@ def test_cli_provider_result(monkeypatch, tmp_path, capsys, provider, http_error
monkeypatch.setenv("VIDEO_GENERATION_PROVIDER", provider)
monkeypatch.setenv("GEMINI_API_KEY", "test-key")
monkeypatch.setenv("MINIMAX_API_KEY", "test-key")
download_url = "https://filecdn.minimax.chat/video.mp4" if provider == "minimax" else "https://generativelanguage.googleapis.com/video.mp4"
prompt = tmp_path / "prompt.json"
prompt.write_text('{"prompt": "A cat runs"}', encoding="utf-8")
output = tmp_path / "video.mp4"
@ -85,10 +87,10 @@ def test_cli_provider_result(monkeypatch, tmp_path, capsys, provider, http_error
if url.endswith("/query/video_generation"):
return response({"status": "Success", "file_id": "file-1"})
if url.endswith("/files/retrieve"):
return response({"file": {"download_url": "https://example.test/video.mp4"}})
return response({"file": {"download_url": download_url}})
if url.endswith("/operations/test"):
return response({"done": True, "response": {"generateVideoResponse": {"generatedSamples": [{"video": {"uri": "https://example.test/video.mp4"}}]}}})
assert url == "https://example.test/video.mp4"
return response({"done": True, "response": {"generateVideoResponse": {"generatedSamples": [{"video": {"uri": download_url}}]}}})
assert url == download_url
return response(content=b"test video")
monkeypatch.setattr(requests, "post", post)

View File

@ -17,6 +17,7 @@ def _mock_provider(monkeypatch, provider):
monkeypatch.setenv("GEMINI_API_KEY", "offline-test-key")
monkeypatch.setenv("MINIMAX_API_KEY", "offline-test-key")
monkeypatch.setenv("MINIMAX_API_HOST", "https://api.example.test")
download_url = "https://filecdn.minimax.chat/video.mp4" if provider == "minimax" else "https://generativelanguage.googleapis.com/video.mp4"
monkeypatch.delenv("MINIMAX_VIDEO_RESOLUTION", raising=False)
monkeypatch.delenv("MINIMAX_VIDEO_DURATION", raising=False)
captured = {"posts": [], "gets": []}
@ -30,12 +31,12 @@ def _mock_provider(monkeypatch, provider):
def fake_get(url, **kwargs):
captured["gets"].append(url)
if url.endswith("/operations/offline-test"):
return FakeResp({"done": True, "response": {"generateVideoResponse": {"generatedSamples": [{"video": {"uri": "https://example.test/video.mp4"}}]}}})
return FakeResp({"done": True, "response": {"generateVideoResponse": {"generatedSamples": [{"video": {"uri": download_url}}]}}})
if url.endswith("/v1/query/video_generation"):
return FakeResp({"status": "Success", "file_id": "offline-file", "base_resp": {"status_code": 0}})
if url.endswith("/v1/files/retrieve"):
return FakeResp({"file": {"download_url": "https://example.test/video.mp4"}, "base_resp": {"status_code": 0}})
assert url == "https://example.test/video.mp4"
return FakeResp({"file": {"download_url": download_url}, "base_resp": {"status_code": 0}})
assert url == download_url
return FakeResp(content=b"offline-video-bytes")
monkeypatch.setattr(vid.requests, "post", fake_post)