web/api: full api request with user preferences

This commit is contained in:
wukko 2024-06-19 23:29:26 +06:00
parent 00cdb2121d
commit 3b2178fd1a
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -1,10 +1,29 @@
import { get } from 'svelte/store';
import settings from "$lib/settings";
import type { CobaltAPIResponse } from "$lib/types/api"; import type { CobaltAPIResponse } from "$lib/types/api";
const apiURL = "https://api.cobalt.tools"; const apiURL = "https://api.cobalt.tools";
const request = async (url: string) => { const request = async (url: string) => {
const saveSettings = get(settings).save;
const request = { const request = {
url url,
isAudioOnly: saveSettings.downloadMode === "audio",
isAudioMuted: saveSettings.downloadMode === "mute",
aFormat: saveSettings.audioFormat,
isTTFullAudio: saveSettings.tiktokFullAudio,
dubLang: saveSettings.youtubeDubBrowserLang,
vCodec: saveSettings.youtubeVideoCodec,
vQuality: saveSettings.videoQuality,
filenamePattern: saveSettings.filenameStyle,
disableMetadata: saveSettings.disableMetadata,
twitterGif: saveSettings.twitterGif,
tiktokH265: saveSettings.tiktokH265,
} }
const response: CobaltAPIResponse | undefined = await fetch(`${apiURL}/api/json`, { const response: CobaltAPIResponse | undefined = await fetch(`${apiURL}/api/json`, {