Skip to main content

vidcache-client

Python client for the vidcache REST API — a content-addressed video cache service with BLAKE3 exact deduplication and perceptual hash matching.

Installation

Install directly from the local package:

pip install ./client

Or add it to a requirements.txt:

dwilson-vidcache-client>=1.0.0

Requires: Python 3.11+, httpx>=0.27.0


Quick start

from vidcache_client import VidCacheClient

client = VidCacheClient("http://localhost:8020")

# Ingest a video URL — runs full dedup pipeline on the server
result = client.ingest(
    url="https://example.com/videos/abc123.mp4",
    bucket="videos",
    prefix="archive",
    meta={"title": "Cool video"},
)

print(result["hash"])    # BLAKE3 hex digest
print(result["status"])  # "new" | "duplicate" | "url_alias"

# Resolve a URL to its hash (no re-ingest)
entry = client.resolve("https://example.com/videos/abc123.mp4")

# Get metadata + all known source URLs
meta = client.get_meta(entry["hash"])
print(meta["duration_s"])
print(meta["aliases"])   # list of all ingested URLs for this video

# Download raw bytes (small files)
video_bytes = client.get_bytes(entry["hash"])

# Stream to a file (recommended for large files)
client.download_to_file(entry["hash"], "video.mp4")

# Stream with manual chunk iteration
with client.stream_video(entry["hash"]) as chunks:
    for chunk in chunks:
        process(chunk)

# Byte-range read (e.g. for seeking)
clip_bytes = client.get_bytes(entry["hash"], byte_range=(0, 1_000_000))

# Delete
client.delete(entry["hash"])

client.close()  # or use as a context manager

Use as a context manager to close the HTTP connection automatically:

with VidCacheClient("http://localhost:8020") as client:
    result = client.ingest(url=url, bucket="videos")

API reference

VidCacheClient(base_url, timeout=300.0, chunk_size=1_048_576)

Parameter Type Description
base_url str Base URL of the vidcache service, e.g. http://localhost:8020
timeout float Request timeout in seconds (default 300.0 — video ingest can be slow)
chunk_size int Byte chunk size for streamed video responses (default 1 MB)

ingest(url, bucket, prefix="", meta=None) → dict

Submit a video URL for caching. Runs the full dedup pipeline on the server (URL lookup → BLAKE3 exact hash → perceptual hash).

Parameter Type Description
url str Source URL of the video
bucket str Storage bucket name
prefix str (optional) Path prefix inside the bucket
meta dict (optional) Arbitrary metadata to store with the video

Returns dict with hash, status ("new" / "duplicate" / "url_alias"), file_path, and optionally phash_distance.


resolve(url) → dict | None

Look up whether a URL has been ingested before. Returns {"hash": …, "url": …} or None.


get_meta(content_hash) → dict | None

Retrieve full metadata for a stored video. Includes hash, size_bytes, duration_s, first_seen, aliases (all known source URLs), and any client-supplied meta. Returns None if not found.


get_bytes(content_hash, byte_range=None) → bytes

Download a stored video as raw bytes. Accepts an optional (start, end) inclusive byte range.


stream_video(content_hash, byte_range=None) → context manager

Stream a stored video as an iterable of byte chunks. Use as a context manager:

with client.stream_video(hash) as chunks:
    for chunk in chunks:
        ...

download_to_file(content_hash, dest, byte_range=None) → int

Stream a video directly to a local file. Returns the number of bytes written.


delete(content_hash) → None

Delete a cached video and all its URL aliases.


close() → None

Close the underlying HTTP connection pool. Called automatically when used as a context manager.

Metadata

Release files for dwilson-vidcache-client 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dwilson-vidcache-client 1.3.0
File Size Uploaded Provenance Actions
dwilson_vidcache_client-1.3.0.tar.gz 5.4 kB Without provenance Details for dwilson_vidcache_client-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dwilson-vidcache-client 1.3.0
File Interpreter ABI Platform Actions
dwilson_vidcache_client-1.3.0-py3-none-any.whl Python 3 none any Details for dwilson_vidcache_client-1.3.0-py3-none-any.whl

Total release size: 11.6 kB

Release files / dwilson_vidcache_client-1.3.0.tar.gz

Download URL dwilson_vidcache_client-1.3.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b6181daa76e95ff1956442b928e295797fde42417456a5fb8b38efaf2028541a
BLAKE2b-256 checksum
How to use checksums
7b074567f5b3573a8eb7b7e32ea406648b1d5a18cbf488a738d77d892d9db4ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / dwilson_vidcache_client-1.3.0-py3-none-any.whl

Download URL dwilson_vidcache_client-1.3.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a7e16a06dce449f6054886ef411945d17d8142effe9cf42c3dcc858a1326e9e
BLAKE2b-256 checksum
How to use checksums
d6a7b5483df084650046739496dbe22c1b5b2dddd241c2bf37d90bd07d0e3e0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for dwilson-vidcache-client 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page