FEATURE: propagate improvements from CLI and web-API versions to web-frontend
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
// web/frontend/src/api/client.ts
|
||||
|
||||
import axios from 'axios'
|
||||
import { TracklistEntry, SplitOptions, TaskStatus, FormatsResponse } from '../types'
|
||||
import {
|
||||
TracklistEntry,
|
||||
SplitOptions,
|
||||
TaskStatus,
|
||||
FormatsResponse,
|
||||
UploadResponse,
|
||||
SplitResponse,
|
||||
} from '../types'
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: '/api',
|
||||
@@ -10,16 +15,14 @@ export const api = axios.create({
|
||||
},
|
||||
})
|
||||
|
||||
export const uploadFile = async (file: File): Promise<{ task_id: string; filename: string; size: number }> => {
|
||||
export const uploadFile = async (file: File): Promise<UploadResponse> => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
const response = await api.post('/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
})
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
@@ -27,12 +30,32 @@ export const startSplit = async (
|
||||
task_id: string,
|
||||
tracklist: TracklistEntry[],
|
||||
options: SplitOptions
|
||||
): Promise<{ task_id: string; status: string }> => {
|
||||
const response = await api.post('/split', {
|
||||
): Promise<SplitResponse> => {
|
||||
// Build request payload (only send fields that are not undefined)
|
||||
const payload: any = {
|
||||
task_id,
|
||||
tracklist,
|
||||
options,
|
||||
})
|
||||
container: options.container, // null means auto-detect
|
||||
audio_codec: options.audio_codec,
|
||||
video_codec: options.video_codec,
|
||||
subtitle_codec: options.subtitle_codec,
|
||||
video_quality: options.video_quality,
|
||||
drop_video: options.drop_video,
|
||||
drop_subs: options.drop_subs,
|
||||
number_tracks: options.number_tracks,
|
||||
replace_bad_chars: options.replace_bad_chars,
|
||||
replacement_char: options.replacement_char,
|
||||
bad_chars: options.bad_chars,
|
||||
skip_existing: options.skip_existing,
|
||||
output_template: options.output_template,
|
||||
album: options.album || null,
|
||||
comment: options.comment || null,
|
||||
no_comment: options.no_comment,
|
||||
comment_stream: options.comment_stream,
|
||||
merge_comments: options.merge_comments,
|
||||
comment_separator: options.comment_separator,
|
||||
}
|
||||
const response = await api.post('/split', payload)
|
||||
return response.data
|
||||
}
|
||||
|
||||
@@ -49,8 +72,7 @@ export const getDownloadZipUrl = (task_id: string): string => {
|
||||
return `/api/download/${task_id}/splits.zip`
|
||||
}
|
||||
|
||||
// New functions for format validation feature
|
||||
export const getFormatInfo = async (): Promise<{ formats: Array<{ name: string; audio_only: boolean }> }> => {
|
||||
export const getFormats = async (): Promise<FormatsResponse> => {
|
||||
const response = await api.get('/formats')
|
||||
return response.data
|
||||
}
|
||||
@@ -70,9 +92,3 @@ export const getRecommendedFormat = async (task_id: string): Promise<{ format: s
|
||||
const response = await api.get(`/info/recommended-format/${task_id}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
// New: fetch containers and codecs
|
||||
export const getFormats = async (): Promise<FormatsResponse> => {
|
||||
const response = await api.get('/formats')
|
||||
return response.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user