Skip to content

Commit 86daf9b

Browse files
committed
gui: restore ffprobe and custom join name
1 parent 4b1f8a6 commit 86daf9b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

yt_audio_backup_gui.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
terminate_all_procs,
3030
verify_tools,
3131
check_and_install_deps,
32+
have,
3233
# File & Audio Logic
3334
_sanitize_and_rename,
3435
_dedup_artist_in_filenames,
3536
join_via_wav_then_lame,
37+
validate_sample_rates,
3638
write_id3_tags_mutagen,
3739
# Playlist & Chapter Logic
3840
write_playlist,
@@ -355,14 +357,16 @@ def _progress(pct: int | None, status: str | None):
355357
write_id3_tags_mutagen(downloaded_files, album_name, _log)
356358
if options.dedup_artist:
357359
downloaded_files = _dedup_artist_in_filenames(downloaded_files, _log)
360+
if options.validate_sr:
361+
validate_sample_rates(downloaded_files, options.sample_rate, _log)
358362
if options.join:
359363
_progress(85, "Joining files...")
360364
joined_file = join_via_wav_then_lame(
361365
files=downloaded_files,
362366
outdir=outdir,
363367
sr=options.sample_rate,
364368
br_kbps=options.bitrate,
365-
join_name="album_joined",
369+
join_name=options.join_name,
366370
log=_log,
367371
shuffle=options.random_join,
368372
keep_temp=options.keep_temp_wavs,
@@ -379,6 +383,24 @@ def _progress(pct: int | None, status: str | None):
379383
outdir, downloaded_files, _log, "playlist", options.playlist_format
380384
)
381385

386+
if options.mp3gain:
387+
_progress(95, "Normalizing volume...")
388+
_log("Applying MP3Gain normalization...")
389+
# Note: We need to import 'have' from the core for this to work
390+
if have("mp3gain"):
391+
files_to_normalize = (
392+
[joined_file]
393+
if options.join and 'joined_file' in locals()
394+
else downloaded_files
395+
)
396+
for f in files_to_normalize:
397+
try:
398+
run_capture(["mp3gain", "-r", "-k", "-p", str(f)])
399+
except Exception as e:
400+
_log(f"mp3gain failed for {f.name}: {e}")
401+
else:
402+
_log("mp3gain not found, skipping normalization.")
403+
382404
_progress(100, "Done")
383405
_log("Run finished successfully.")
384406

0 commit comments

Comments
 (0)