web/save: add support for audio bitrate functionality

This commit is contained in:
wukko 2024-08-22 19:38:39 +06:00
parent 91fd26e880
commit 49184a235d
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
5 changed files with 27 additions and 4 deletions

View file

@ -49,15 +49,19 @@
"audio.format.ogg": "ogg", "audio.format.ogg": "ogg",
"audio.format.wav": "wav", "audio.format.wav": "wav",
"audio.format.opus": "opus", "audio.format.opus": "opus",
"audio.format.description": "every format but \"best\" is converted, meaning that they're lossy. if preferred format matches best available audio, it won't be converted.", "audio.format.description": "all formats but \"best\" are converted, meaning that there'll be some quality loss. if preferred format matches best available audio, it won't be converted.",
"audio.bitrate": "audio bitrate",
"audio.bitrate.kbps": "kb/s",
"audio.bitrate.description": "preferred bitrate to use when converting audio. final perceived quality may differ based on the format.",
"audio.youtube.dub": "youtube", "audio.youtube.dub": "youtube",
"audio.youtube.dub.title": "use browser language for dubbed videos", "audio.youtube.dub.title": "use browser language for dubbed videos",
"audio.youtube.dub.description": "works even if cobalt isn't translated to your language.", "audio.youtube.dub.description": "works even if cobalt isn't translated to your language.",
"audio.tiktok.original": "tiktok", "audio.tiktok.original": "tiktok",
"audio.tiktok.original.title": "use original sound", "audio.tiktok.original.title": "download original sound",
"audio.tiktok.original.description": "downloads original sound used in the post without any additional changes by the post's author.", "audio.tiktok.original.description": "if enabled, cobalt will download the sound from the post without any changes by the post's author.",
"metadata.filename": "filename style", "metadata.filename": "filename style",
"metadata.filename.classic": "classic", "metadata.filename.classic": "classic",

View file

@ -16,6 +16,7 @@ const request = async (url: string) => {
downloadMode: saveSettings.downloadMode, downloadMode: saveSettings.downloadMode,
audioBitrate: saveSettings.audioBitrate,
audioFormat: saveSettings.audioFormat, audioFormat: saveSettings.audioFormat,
tiktokFullAudio: saveSettings.tiktokFullAudio, tiktokFullAudio: saveSettings.tiktokFullAudio,
youtubeDubBrowserLang: saveSettings.youtubeDubBrowserLang, youtubeDubBrowserLang: saveSettings.youtubeDubBrowserLang,

View file

@ -15,6 +15,7 @@ const defaultSettings: CobaltSettings = {
reduceTransparency: false, reduceTransparency: false,
}, },
save: { save: {
audioBitrate: "256",
audioFormat: "mp3", audioFormat: "mp3",
disableMetadata: false, disableMetadata: false,
downloadMode: "auto", downloadMode: "auto",

View file

@ -2,6 +2,7 @@ import languages from '$i18n/languages.json';
import type { RecursivePartial } from './generic'; import type { RecursivePartial } from './generic';
export const themeOptions = ["auto", "light", "dark"] as const; export const themeOptions = ["auto", "light", "dark"] as const;
export const audioBitrateOptions = ["320", "256", "128", "96", "64"] as const;
export const audioFormatOptions = ["best", "mp3", "ogg", "wav", "opus"] as const; export const audioFormatOptions = ["best", "mp3", "ogg", "wav", "opus"] as const;
export const downloadModeOptions = ["auto", "audio", "mute"] as const; export const downloadModeOptions = ["auto", "audio", "mute"] as const;
export const filenameStyleOptions = ["classic", "basic", "pretty", "nerdy"] as const; export const filenameStyleOptions = ["classic", "basic", "pretty", "nerdy"] as const;
@ -32,6 +33,7 @@ type CobaltSettingsProcessing = {
type CobaltSettingsSave = { type CobaltSettingsSave = {
audioFormat: typeof audioFormatOptions[number], audioFormat: typeof audioFormatOptions[number],
audioBitrate: typeof audioBitrateOptions[number],
disableMetadata: boolean, disableMetadata: boolean,
downloadMode: typeof downloadModeOptions[number], downloadMode: typeof downloadModeOptions[number],
filenameStyle: typeof filenameStyleOptions[number], filenameStyle: typeof filenameStyleOptions[number],

View file

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { t } from "$lib/i18n/translations"; import { t } from "$lib/i18n/translations";
import { audioFormatOptions } from "$lib/types/settings"; import { audioFormatOptions, audioBitrateOptions } from "$lib/types/settings";
import SettingsCategory from "$components/settings/SettingsCategory.svelte"; import SettingsCategory from "$components/settings/SettingsCategory.svelte";
import Switcher from "$components/buttons/Switcher.svelte"; import Switcher from "$components/buttons/Switcher.svelte";
@ -23,6 +23,21 @@
</Switcher> </Switcher>
</SettingsCategory> </SettingsCategory>
<SettingsCategory sectionId="audio-bitrate" title={$t("settings.audio.bitrate")}>
<Switcher big={true} description={$t("settings.audio.bitrate.description")}>
{#each audioBitrateOptions as value}
<SettingsButton
settingContext="save"
settingId="audioBitrate"
settingValue={value}
>
{value}{$t("settings.audio.bitrate.kbps")}
</SettingsButton>
{/each}
</Switcher>
</SettingsCategory>
<SettingsCategory sectionId="youtube" title={$t("settings.audio.youtube.dub")}> <SettingsCategory sectionId="youtube" title={$t("settings.audio.youtube.dub")}>
<SettingsToggle <SettingsToggle
settingContext="save" settingContext="save"