Tracs validation added. A warning is thrown if the input contains a video strem, but the requested output format doesn't support it
This commit is contained in:
@@ -3,7 +3,8 @@ import { useDropzone } from 'react-dropzone'
|
||||
import { Box, Typography, Paper, LinearProgress, Alert } from '@mui/material'
|
||||
import { CloudUpload, InsertDriveFile } from '@mui/icons-material'
|
||||
import { useUploadStore } from '../stores/uploadStore'
|
||||
import { uploadFile } from '../api/client'
|
||||
import { uploadFile, getTaskInfo } from '../api/client'
|
||||
import { useTaskStore } from '../stores/taskStore'
|
||||
|
||||
const ALLOWED_EXTENSIONS = ['.mp3', '.flac', '.wav', '.m4a', '.ogg', '.opus', '.aac', '.wma', '.aiff', '.alac', '.ac3']
|
||||
|
||||
@@ -22,8 +23,14 @@ export const UploadZone: React.FC = () => {
|
||||
setUploadProgress,
|
||||
setError,
|
||||
setTaskId,
|
||||
setHasVideo,
|
||||
setHasAudio,
|
||||
setHasSubtitle,
|
||||
setAudioCodec,
|
||||
} = useUploadStore()
|
||||
|
||||
const { setTaskId: setTaskIdStore } = useTaskStore()
|
||||
|
||||
const onDrop = useCallback(
|
||||
async (acceptedFiles: File[]) => {
|
||||
if (acceptedFiles.length === 0) return
|
||||
@@ -45,9 +52,23 @@ export const UploadZone: React.FC = () => {
|
||||
|
||||
try {
|
||||
const response = await uploadFile(selectedFile)
|
||||
setTaskId(response.task_id)
|
||||
const taskId = response.task_id
|
||||
setTaskId(taskId)
|
||||
setTaskIdStore(taskId)
|
||||
setUploadProgress(100)
|
||||
setIsUploading(false)
|
||||
|
||||
// Fetch stream info
|
||||
try {
|
||||
const info = await getTaskInfo(taskId)
|
||||
setHasVideo(info.has_video)
|
||||
setHasAudio(info.has_audio)
|
||||
setHasSubtitle(info.has_subtitle)
|
||||
setAudioCodec(info.audio_codec)
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch stream info:', err)
|
||||
// Don't block the upload flow if this fails; we'll just assume no video
|
||||
}
|
||||
} catch (err: any) {
|
||||
setError(err.response?.data?.detail || err.message || 'Upload failed')
|
||||
setIsUploading(false)
|
||||
@@ -57,7 +78,7 @@ export const UploadZone: React.FC = () => {
|
||||
setFileSize(0)
|
||||
}
|
||||
},
|
||||
[setFile, setFileName, setFileSize, setIsUploading, setUploadProgress, setError, setTaskId]
|
||||
[setFile, setFileName, setFileSize, setIsUploading, setUploadProgress, setError, setTaskId, setTaskIdStore]
|
||||
)
|
||||
|
||||
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
||||
|
||||
Reference in New Issue
Block a user