Fix broken abcde command: build output_fmt before cmd construction

cmd[-2] was overwriting the -a action value instead of the -o format
value when -P was appended last. Now output_fmt is computed upfront and
the cmd list is built cleanly without post-hoc index manipulation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-02-17 21:10:11 +01:00
commit 8765e991b0

View file

@ -296,37 +296,37 @@ def _rip_with_abcde(
""" """
output_dir.mkdir(parents=True, exist_ok=True) output_dir.mkdir(parents=True, exist_ok=True)
# Build output format string: "flac" or "flac:-8" (with quality options)
encoder_opts = audio_format.get_encoder_options(quality)
output_fmt = audio_format.get_abcde_format()
if encoder_opts:
output_fmt = f"{output_fmt}:{encoder_opts}"
# abcde options: # abcde options:
# -a actions: cddb+read+encode+tag (no 'move' — we extract files ourselves) # -a actions: cddb+read+encode+tag (no 'move' — we extract files ourselves)
# -p: pad track numbers with zeros # -p: pad track numbers with zeros
# -o format: output format # -o format[:options]: output format with optional encoder options
# -d device: CD drive # -d device: CD drive
# -x: eject CD after ripping # -x: eject CD after ripping
# -N: non-interactive (auto-select first CDDB match, no prompts) # -N: non-interactive (auto-select first CDDB match, no prompts)
actions = "cddb,read,encode,tag" if use_cddb else "read,encode"
cmd = [ cmd = [
"abcde", "abcde",
"-a", actions,
"-p", "-p",
"-o", audio_format.get_abcde_format(), "-o", output_fmt,
"-d", device, "-d", device,
"-x", "-x",
"-N", "-N",
] ]
if use_cddb:
cmd.extend(["-a", "cddb,read,encode,tag"])
else:
cmd.extend(["-a", "read,encode"])
if parallel_jobs > 1: if parallel_jobs > 1:
cmd.extend(["-j", str(parallel_jobs)]) cmd.extend(["-j", str(parallel_jobs)])
if use_pipes: if use_pipes:
cmd.append("-P") cmd.append("-P")
encoder_opts = audio_format.get_encoder_options(quality)
if encoder_opts:
cmd[-2] = f"{audio_format.get_abcde_format()}:{encoder_opts}"
print(f"\n Command: {' '.join(cmd)}", flush=True) print(f"\n Command: {' '.join(cmd)}", flush=True)
logger.info("Starting abcde: %s", " ".join(cmd)) logger.info("Starting abcde: %s", " ".join(cmd))