diff options
| author | Dennis Fink | 2026-05-23 15:02:49 +0200 |
|---|---|---|
| committer | Dennis Fink | 2026-05-23 15:02:49 +0200 |
| commit | a049faf194165e74c8d75c85bb4473fedf7e6dbd (patch) | |
| tree | 53786851f67b7a1fad48660f9bfac2984c1d5d35 | |
| parent | 0910e859f53e4ccc512006eb843ac0ea459844cd (diff) | |
| download | transcode.sh-a049faf194165e74c8d75c85bb4473fedf7e6dbd.tar.gz transcode.sh-a049faf194165e74c8d75c85bb4473fedf7e6dbd.zip | |
refactor(config): simplify skip codec loading
Load configured skip codecs through the same parser used for CLI values
instead of iterating over TOML array entries separately.
This keeps skip codec normalization and empty-token handling in one
place while preserving the merged config and CLI behavior.
Clarify config debug messages with full TOML key names and include the
continue setting in the effective configuration output.
Diffstat (limited to '')
| -rwxr-xr-x | transcode.sh | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/transcode.sh b/transcode.sh index c2d41b6..b9aee8b 100755 --- a/transcode.sh +++ b/transcode.sh @@ -535,7 +535,7 @@ function load_config() { if [[ $_CLI_PRESET -eq 0 ]]; then val=$(_tomlq_get '.encoding.preset // empty') if [[ -n "$val" ]]; then - debug "Config: preset =" "$val" + debug "Config: encoding.preset =" "$val" PRESET_NAME="$val" fi fi @@ -544,7 +544,7 @@ function load_config() { if [[ $_CLI_NICE -eq 0 ]]; then val=$(_tomlq_get '.encoding.nice // empty') if [[ -n "$val" ]]; then - debug "Config: nice =" "$val" + debug "Config: encoding.nice =" "$val" NICE_VALUE="$val" fi fi @@ -627,15 +627,16 @@ function load_config() { fi fi - # [skip] codecs (TOML array → one element per line via tomlq -r '.skip.codecs[]') + # [skip] codecs + # TOML array values are joined and passed through the same parser as CLI --skip-codec. # CLI --skip-codec entries are additive, so we always load config codecs - # regardless of _CLI_SKIP_CODEC. Both sources merge into SKIP_CODECS. - local codec - while IFS= read -r codec; do - if [[ -n "$codec" ]]; then - add_skip_codec_token "$codec" - fi - done < <(tomlq -r '.skip.codecs[]?' "$CONFIG_FILE" 2>/dev/null) + # regardless of _CLI_SKIP_CODEC. Both sources merge into SKIP_CODECS, except + # if --skip-codec-override is specified + val=$(_tomlq_get '(.skip.codecs | join(", "))?') + if [[ -n "$val" ]]; then + debug "Config: skip.codecs =" "$val" + parse_skip_codec_parameter "$val" + fi # [size_report] enabled if [[ $_CLI_SIZE_REPORT -eq 0 ]]; then @@ -703,9 +704,14 @@ function load_config() { # Add a codec name to the SKIP_CODECS associative array. # - Normalizes to lowercase # - Ignores empty tokens -# - Used both for CLI --skip-codec and for codecs defined +# - Used both for CLI --skip-codec and for codecs defined in the config file function add_skip_codec_token() { local token="${1,,}" # lowercase + + if [[ -z "$token" ]]; then + return 0 + fi + if [[ ! -v SKIP_CODECS["$token"] ]]; then debug "Add to skip codec:" "$token" SKIP_CODECS["$token"]= @@ -720,9 +726,7 @@ function parse_skip_codec_parameter() { local arg="$1" local IFS=',: ' token for token in $arg; do - if [[ ! -z "$token" ]]; then - add_skip_codec_token "$token" - fi + add_skip_codec_token "$token" done } @@ -1792,6 +1796,7 @@ printf -v joined ' %s' "${!SKIP_CODECS[@]}" debug "Effective configuration:" debug " backup-dir:" "$BACKUP_DIR" debug " config-file:" "$CONFIG_FILE" +debug " continue:" "$CONTINUE_ON_FAIL" debug " dry-run:" "$DRY_RUN" debug " encode-file:" "$ENCODE_FILE" debug " ffmpeg-loglevel:" "$FFMPEG_LOGLEVEL" |
