Fix subtitle API to send file as FormData instead of asset_id
This commit is contained in:
parent
c6167f33f0
commit
5b2ef4c8f2
1 changed files with 18 additions and 14 deletions
|
|
@ -115,7 +115,7 @@ export default function SubtitlesPage() {
|
|||
};
|
||||
|
||||
const handleProcess = async () => {
|
||||
if (!assetId) {
|
||||
if (!file) {
|
||||
toast.error('Please upload a video first');
|
||||
return;
|
||||
}
|
||||
|
|
@ -124,18 +124,22 @@ export default function SubtitlesPage() {
|
|||
setResults(null);
|
||||
|
||||
try {
|
||||
const response = await modulesApi.processSubtitles({
|
||||
asset_id: assetId,
|
||||
source_language: sourceLanguage || undefined,
|
||||
target_language: targetLanguage || undefined,
|
||||
burn_subtitles: burnSubtitles,
|
||||
font,
|
||||
font_size: fontSize,
|
||||
text_color: textColor,
|
||||
outline_color: outlineColor,
|
||||
outline_width: outlineWidth,
|
||||
position,
|
||||
});
|
||||
// Create FormData with file and all parameters
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('source_language', sourceLanguage || 'auto');
|
||||
if (targetLanguage) {
|
||||
formData.append('target_language', targetLanguage);
|
||||
}
|
||||
formData.append('burn_subtitles', String(burnSubtitles));
|
||||
formData.append('font', font);
|
||||
formData.append('font_size', String(fontSize));
|
||||
formData.append('text_color', textColor);
|
||||
formData.append('outline_color', outlineColor);
|
||||
formData.append('outline_width', String(outlineWidth));
|
||||
formData.append('position', position);
|
||||
|
||||
const response = await modulesApi.processSubtitles(formData);
|
||||
|
||||
const job = response.data;
|
||||
setJobId(job.id);
|
||||
|
|
@ -388,7 +392,7 @@ export default function SubtitlesPage() {
|
|||
{/* Process Button */}
|
||||
<button
|
||||
onClick={handleProcess}
|
||||
disabled={loading || !assetId || uploading}
|
||||
disabled={loading || !file || uploading}
|
||||
className="btn-primary w-full flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
<Sparkles className="w-5 h-5" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue