From ade2c3ffffa1418796ca665e2ea80555021594fd Mon Sep 17 00:00:00 2001 From: CodeConscious <50596087+codeconscious@users.noreply.github.com> Date: Sun, 11 Aug 2024 21:06:07 +0900 Subject: [PATCH] Add audio quality setting --- src/CCVTAC.Console/Downloading/Downloader.cs | 2 +- src/CCVTAC.FSharp/Settings.fs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/CCVTAC.Console/Downloading/Downloader.cs b/src/CCVTAC.Console/Downloading/Downloader.cs index b00ee84..f37b47e 100644 --- a/src/CCVTAC.Console/Downloading/Downloader.cs +++ b/src/CCVTAC.Console/Downloading/Downloader.cs @@ -108,7 +108,7 @@ private static string GenerateDownloadArgs( _ => [ "--extract-audio", settings.AudioFormat == "default" ? string.Empty : $"-f {settings.AudioFormat}", - "--audio-quality 0", // Highest quality + $"--audio-quality {settings.AudioQuality}", "--write-thumbnail --convert-thumbnails jpg", // For album art writeJson, // Contains metadata trimFileNames, diff --git a/src/CCVTAC.FSharp/Settings.fs b/src/CCVTAC.FSharp/Settings.fs index d5d80a0..99584fd 100644 --- a/src/CCVTAC.FSharp/Settings.fs +++ b/src/CCVTAC.FSharp/Settings.fs @@ -33,6 +33,7 @@ module Settings = [] HistoryFile: string [] HistoryDisplayCount: byte [] AudioFormat: string + [] AudioQuality: byte [] SplitChapters: bool [] SleepSecondsBetweenDownloads: uint16 [] SleepSecondsBetweenBatches: uint16 @@ -81,6 +82,8 @@ module Settings = onOrOff settings.QuietMode) ("Audio format", summarizeAudioFormat settings.AudioFormat) + ("Audio quality (10 up to 0)", + settings.AudioQuality |> sprintf "%B") ("Sleep between batches (URLs)", settings.SleepSecondsBetweenBatches |> int |> pluralize "second") ("Sleep between downloads", @@ -156,9 +159,11 @@ module Settings = Error $"No move-to directory was specified." | { MoveToDirectory = m } when dirMissing m -> Error $"Move-to directory \"{m}\" is missing." + | { AudioQuality = q } when q > 10uy -> + Error $"Audio quality must be between 10 (lowest) and 0 (highest)." | { AudioFormat = af } when not (validAudioFormat af) -> let approved = supportedAudioFormats |> String.concat ", " - Error $"{af} is not a valid audio format. Use \"default\" or one of the following: {approved}." + Error $"\"{af}\" is not a valid audio format. Use \"default\" or one of the following: {approved}." | _ -> Ok settings @@ -204,6 +209,7 @@ module Settings = SleepSecondsBetweenDownloads = 10us SleepSecondsBetweenBatches = 20us AudioFormat = String.Empty + AudioQuality = 0uy QuietMode = false EmbedImages = true DoNotEmbedImageUploaders = [||]