Skip to content

Commit

Permalink
Add audio quality setting
Browse files Browse the repository at this point in the history
  • Loading branch information
codeconscious committed Aug 11, 2024
1 parent a4bf496 commit ade2c3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/CCVTAC.Console/Downloading/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion src/CCVTAC.FSharp/Settings.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module Settings =
[<JsonPropertyName("historyFile")>] HistoryFile: string
[<JsonPropertyName("historyDisplayCount")>] HistoryDisplayCount: byte
[<JsonPropertyName("audioFormat")>] AudioFormat: string
[<JsonPropertyName("audioQuality")>] AudioQuality: byte
[<JsonPropertyName("splitChapters")>] SplitChapters: bool
[<JsonPropertyName("sleepSecondsBetweenDownloads")>] SleepSecondsBetweenDownloads: uint16
[<JsonPropertyName("sleepSecondsBetweenBatches")>] SleepSecondsBetweenBatches: uint16
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -204,6 +209,7 @@ module Settings =
SleepSecondsBetweenDownloads = 10us
SleepSecondsBetweenBatches = 20us
AudioFormat = String.Empty
AudioQuality = 0uy
QuietMode = false
EmbedImages = true
DoNotEmbedImageUploaders = [||]
Expand Down

0 comments on commit ade2c3f

Please sign in to comment.