"""The media-kind discriminator for a library asset — the single home of one invariant. `MediaAsset.media_kind` is `"video" | "audio" | "file"`. It decides which library actions apply: media (video/audio) gets play/edit/share; a generic uploaded file gets download + share only, and is never rendered inline (see the force-download serving in the file/watch routes). Every finalize path computes it HERE — the download worker + the upload ingest via `derive`, the editor by carrying the source's kind over — so the rule lives in code, not in a comment that can drift (an earlier ad-hoc `vcodec is None and acodec is not None` audio check lived only in links.py). """ VIDEO = "video" AUDIO = "audio" FILE = "file" def derive(vcodec: str | None, acodec: str | None) -> str: """Media kind from the probed codecs: a video stream -> video, audio-only -> audio, neither (a non-media upload: pdf/zip/docx/…) -> file.""" if vcodec: return VIDEO if acodec: return AUDIO return FILE