feat(uploads): a video track is no longer a reason to reject (ADR-033)
Only no-audio, unreadable length and too-long are refused. ReasonVideo is gone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,8 @@ type Limits struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Probe is what inspecting an uploaded file revealed. It is the input to Validate
|
// Probe is what inspecting an uploaded file revealed. It is the input to Validate
|
||||||
// because a name or MIME type cannot say whether a container carries video: a
|
// because a name or MIME type cannot say what a container holds: a Teams recording
|
||||||
// Teams voice-only export is typically an .mp4 with no video stream.
|
// is an .mp4 whether or not the camera was on.
|
||||||
type Probe struct {
|
type Probe struct {
|
||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
HasAudio bool
|
HasAudio bool
|
||||||
@@ -30,7 +30,6 @@ type Probe struct {
|
|||||||
type Reason string
|
type Reason string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ReasonVideo Reason = "video"
|
|
||||||
ReasonNoAudio Reason = "no_audio"
|
ReasonNoAudio Reason = "no_audio"
|
||||||
ReasonTooLong Reason = "too_long"
|
ReasonTooLong Reason = "too_long"
|
||||||
ReasonTooLarge Reason = "too_large"
|
ReasonTooLarge Reason = "too_large"
|
||||||
@@ -46,13 +45,13 @@ type RejectError struct {
|
|||||||
|
|
||||||
func (e *RejectError) Error() string { return string(e.Reason) + ": " + e.Message }
|
func (e *RejectError) Error() string { return string(e.Reason) + ": " + e.Message }
|
||||||
|
|
||||||
// Validate decides whether a probed file may be transcribed. Video is checked
|
// Validate decides whether a probed file may be transcribed. A video track is NOT
|
||||||
// first so a video file is always refused as video, whatever its length.
|
// a reason to refuse: a Teams meeting with the camera off is still an .mp4 with a
|
||||||
|
// video track, so rejecting video would reject the primary use case. Only the audio
|
||||||
|
// is used (Probe.HasVideo is recorded so the user can be told the video was
|
||||||
|
// ignored). What IS refused: no audio at all, an unreadable length, too long.
|
||||||
func Validate(p Probe, l Limits) error {
|
func Validate(p Probe, l Limits) error {
|
||||||
switch {
|
switch {
|
||||||
case p.HasVideo:
|
|
||||||
return &RejectError{Reason: ReasonVideo, Message: "This file contains a video track. " +
|
|
||||||
"Only audio recordings are supported for now; video upload is tracked in issue #28."}
|
|
||||||
case !p.HasAudio:
|
case !p.HasAudio:
|
||||||
return &RejectError{Reason: ReasonNoAudio, Message: "This file has no audio track to transcribe."}
|
return &RejectError{Reason: ReasonNoAudio, Message: "This file has no audio track to transcribe."}
|
||||||
case p.Duration <= 0:
|
case p.Duration <= 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user