Backend MP4 conversion (#23)
* ADD conversion queue * ADD RemuxService for MP4 conversion * REMOVE unused conversion queue * REORGANISE Job-related classes * ADD Job stages * REVERT to old commit, using Spring Async instead * ADD asynchronous processing for video tasks * PATCH and streamline progress tracking * ADD asynchronous video processing and job restructuring * REFACTOR job service method * ADD job remux functionality * ADD remuxing endpoint * PATCH complete flag not updating in API response * ADD progress type in frontend * ADD reset functionality for job status * PATCH missing progress bar for subsequent exports * REDESIGN settings box * ADD tracking video file conversion in frontend * PATCH extension bug * REMOVE autowired decorator
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type {VideoMetadata, APIResponse, User, Clip} from "./types.ts";
|
||||
import type {VideoMetadata, APIResponse, User, Clip, ProgressResult } from "./types.ts";
|
||||
|
||||
/**
|
||||
* Uploads a file to the backend.
|
||||
@@ -74,11 +74,25 @@ const processFile = async (uuid: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const convertFile = async (uuid: string) => {
|
||||
const response = await fetch(`/api/v1/convert/${uuid}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to convert file: ${response.status}`);
|
||||
}
|
||||
|
||||
const result: APIResponse = await response.json();
|
||||
|
||||
if (result.status === "error") {
|
||||
throw new Error("Failed to convert file: " + result.message);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the processing progress percentage.
|
||||
* @param uuid - The UUID of the video file.
|
||||
*/
|
||||
const getProgress = async (uuid: string): Promise<number> => {
|
||||
const getProgress = async (uuid: string): Promise<ProgressResult> => {
|
||||
const response = await fetch(`/api/v1/progress/${uuid}`);
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -91,11 +105,11 @@ const getProgress = async (uuid: string): Promise<number> => {
|
||||
throw new Error(`Failed to fetch progress: ${result.message}`);
|
||||
}
|
||||
|
||||
if (!result.data || typeof result.data.progress !== 'number') {
|
||||
if (!result.data) {
|
||||
throw new Error('Invalid progress data received');
|
||||
}
|
||||
|
||||
return result.data.progress;
|
||||
return result.data;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -189,6 +203,7 @@ export {
|
||||
uploadFile,
|
||||
editFile,
|
||||
processFile,
|
||||
convertFile,
|
||||
getProgress,
|
||||
getMetadata,
|
||||
getUser,
|
||||
|
||||
@@ -30,9 +30,21 @@ type Clip = {
|
||||
createdAt: string,
|
||||
}
|
||||
|
||||
type ProgressResult = {
|
||||
process: {
|
||||
progress: number,
|
||||
complete: boolean
|
||||
};
|
||||
conversion: {
|
||||
progress: number,
|
||||
complete: boolean
|
||||
};
|
||||
};
|
||||
|
||||
export type {
|
||||
APIResponse,
|
||||
VideoMetadata,
|
||||
User,
|
||||
Clip
|
||||
Clip,
|
||||
ProgressResult
|
||||
}
|
||||
Reference in New Issue
Block a user