refactor(frontend): move media blob fetch function to endpoint file

This commit is contained in:
2026-02-22 21:38:08 +00:00
parent 0c5b93571b
commit ab943be44e
2 changed files with 23 additions and 18 deletions

View File

@@ -239,6 +239,20 @@ const getClipById = async (id: string): Promise<Clip | null> => {
}
};
const getVideoBlob = async(id: string): Promise<Blob> => {
const response = await fetch(API_URL + `/api/v1/download/clip/${id}`, {credentials: "include",});
if (!response.ok) {
throw new Error(`Failed to fetch video: ${id}: ${response.status}`)
}
try {
return response.blob();
} catch {
throw new Error(`Failed to convert Clip Return Object to blob`);
}
}
const isThumbnailAvailable = async (id: number): Promise<boolean> => {
const response = await fetch(API_URL + `/api/v1/download/thumbnail/${id}`, {credentials: "include"});
if (!response.ok) {
@@ -260,5 +274,6 @@ export {
getUser,
getClips,
getClipById,
getVideoBlob,
isThumbnailAvailable
};