From 89c29dda27b6243e79523ab563d14cf9d2d70541 Mon Sep 17 00:00:00 2001 From: Shayanide Date: Sun, 30 Aug 2026 06:51:22 +0000 Subject: [PATCH] Render video validation errors --- README.md | 4 ++++ src/datapoint/formatting.py | 6 ++++++ tests/test_formatting.py | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 3b02f05..8c44523 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,10 @@ datapoint filters [--country C] [--region R] [--city K] [--postal P] Every read command supports `--json` for machine-readable output you can pipe into `jq` or another tool. +Video uploads accept browser-compatible H.264 MP4/MOV or VP8/VP9 WebM files. +The API validates the actual media bytes before storage and reports unsupported, +unreadable, or temporarily unprobeable videos directly in the CLI. + ## How `survey create` works `survey create` reserves credits and dispatches paid human work within seconds — diff --git a/src/datapoint/formatting.py b/src/datapoint/formatting.py index 445a3fb..c69ec6d 100644 --- a/src/datapoint/formatting.py +++ b/src/datapoint/formatting.py @@ -571,6 +571,12 @@ def describe_media_error(detail) -> str: return f"unsupported file type ({ext})" if ext else "unsupported file type" if code == "media_type_mismatch": return "file contents do not match its extension" + if code == "unsupported_video_format": + return str(detail.get("message") or "unsupported video format (use H.264 MP4/MOV or VP8/VP9 WebM)") + if code == "invalid_video": + return str(detail.get("message") or detail.get("reason") or "invalid or unreadable video") + if code == "video_validation_unavailable": + return str(detail.get("message") or "video format validation is temporarily unavailable; please retry") if code == "invalid_svg": reason = detail.get("reason") return f"invalid SVG: {reason}" if reason else "invalid SVG" diff --git a/tests/test_formatting.py b/tests/test_formatting.py index 3c4b034..9f805f3 100644 --- a/tests/test_formatting.py +++ b/tests/test_formatting.py @@ -121,6 +121,18 @@ def test_describe_media_error_codes(): assert f.describe_media_error("plain string") == "plain string" +def test_describe_video_validation_errors(): + unsupported = { + "code": "unsupported_video_format", + "message": "Unsupported video codec: hevc. Supported: h264.", + } + assert f.describe_media_error(unsupported) == unsupported["message"] + assert f.describe_media_error({"code": "invalid_video", "reason": "The file is not a readable video."}) == ( + "The file is not a readable video." + ) + assert "temporarily unavailable" in f.describe_media_error({"code": "video_validation_unavailable"}) + + def test_render_report_statuses(): assert "not started" in f.render_report({"job_id": "j", "status": "not_started"}).lower() assert "generating" in f.render_report({"job_id": "j", "status": "generating"}).lower()