mirror of
https://github.com/rwinkhart/flac2pod.git
synced 2026-09-06 00:57:14 -04:00
Add support for skipping conversions on non-FLAC files
This commit is contained in:
+5
-1
@@ -3,7 +3,7 @@
|
|||||||
# external modules
|
# external modules
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from mutagen.flac import FLAC
|
from mutagen.flac import FLAC, FLACNoHeaderError
|
||||||
from os import cpu_count, path, walk
|
from os import cpu_count, path, walk
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import check_output, Popen
|
from subprocess import check_output, Popen
|
||||||
@@ -61,6 +61,7 @@ def scan_destination_convert():
|
|||||||
_i += 1
|
_i += 1
|
||||||
print(f"\n{_progress}% | \u001b[38;5;0;48;5;15mConverting {_file_s} to {_file_d}...\u001b[0m\n")
|
print(f"\n{_progress}% | \u001b[38;5;0;48;5;15mConverting {_file_s} to {_file_d}...\u001b[0m\n")
|
||||||
# get relevant ReplayGain info
|
# get relevant ReplayGain info
|
||||||
|
try:
|
||||||
_audio = FLAC(f"{_file}.flac")
|
_audio = FLAC(f"{_file}.flac")
|
||||||
if args.albumgain:
|
if args.albumgain:
|
||||||
if _audio.get('REPLAYGAIN_ALBUM_GAIN'):
|
if _audio.get('REPLAYGAIN_ALBUM_GAIN'):
|
||||||
@@ -88,6 +89,9 @@ def scan_destination_convert():
|
|||||||
_rgpeak = float(_audio.get('replaygain_track_peak')[0])
|
_rgpeak = float(_audio.get('replaygain_track_peak')[0])
|
||||||
else:
|
else:
|
||||||
_rgpeak = None
|
_rgpeak = None
|
||||||
|
except FLACNoHeaderError:
|
||||||
|
print(f"[{_file_s}] Not a FLAC file, skipping...")
|
||||||
|
_rggain, _rgpeak = None, None
|
||||||
# determine ffmpeg arguments
|
# determine ffmpeg arguments
|
||||||
if args.bake and _rggain is not None:
|
if args.bake and _rggain is not None:
|
||||||
_bake_args, _flac2pod_rg_tags = '-filter:a "volume=' + str(_rggain) + 'dB"', ''
|
_bake_args, _flac2pod_rg_tags = '-filter:a "volume=' + str(_rggain) + 'dB"', ''
|
||||||
|
|||||||
Reference in New Issue
Block a user