0.10.0 Audbile Prototype
This commit is contained in:
@@ -78,11 +78,13 @@ function afterMutationInvalidate(prefixes = []) {
|
||||
}
|
||||
|
||||
async function request(path, options = {}) {
|
||||
const isFormDataBody = typeof FormData !== 'undefined' && options?.body instanceof FormData;
|
||||
const mergedHeaders = {
|
||||
...(isFormDataBody ? {} : { 'Content-Type': 'application/json' }),
|
||||
...(options.headers || {})
|
||||
};
|
||||
const response = await fetch(`${API_BASE}${path}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(options.headers || {})
|
||||
},
|
||||
headers: mergedHeaders,
|
||||
...options
|
||||
});
|
||||
|
||||
@@ -301,6 +303,24 @@ export const api = {
|
||||
afterMutationInvalidate(['/history', '/pipeline/queue']);
|
||||
return result;
|
||||
},
|
||||
async uploadAudiobook(file, payload = {}) {
|
||||
const formData = new FormData();
|
||||
if (file) {
|
||||
formData.append('file', file);
|
||||
}
|
||||
if (payload?.format) {
|
||||
formData.append('format', String(payload.format));
|
||||
}
|
||||
if (payload?.startImmediately !== undefined) {
|
||||
formData.append('startImmediately', String(payload.startImmediately));
|
||||
}
|
||||
const result = await request('/pipeline/audiobook/upload', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
afterMutationInvalidate(['/history', '/pipeline/queue']);
|
||||
return result;
|
||||
},
|
||||
async selectMetadata(payload) {
|
||||
const result = await request('/pipeline/select-metadata', {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user