Catch enabling conversion without specifying codec

Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
nathom 2021-06-10 10:44:23 -07:00
parent 14710d536a
commit df29a338c6
2 changed files with 14 additions and 7 deletions

View file

@ -570,7 +570,14 @@ class Track:
"M4A": converter.AAC, "M4A": converter.AAC,
} }
try:
self.container = codec.upper() self.container = codec.upper()
except AttributeError:
click.secho(
"Error: No audio codec chosen to convert to.", fg="red"
)
raise click.Abort
if not hasattr(self, "final_path"): if not hasattr(self, "final_path"):
self.format_final_path() self.format_final_path()

View file

@ -242,12 +242,12 @@ class Album(Tracklist):
""" """
fmt = {key: self.get(key) for key in ALBUM_KEYS} fmt = {key: self.get(key) for key in ALBUM_KEYS}
max_bd, max_sr = get_stats_from_quality(self.quality) stats = get_stats_from_quality(self.quality)
if max_sr < fmt.get("sampling_rate", 0) or max_bd < fmt.get(
"bit_depth", 0 # The quality chosen is not the maximum available quality
): if stats != (fmt.get("sampling_rate"), fmt.get("bit_depth")):
fmt["sampling_rate"] = max_sr fmt["bit_depth"] = stats[0]
fmt["bit_depth"] = max_bd fmt["sampling_rate"] = stats[1]
if sr := fmt.get("sampling_rate"): if sr := fmt.get("sampling_rate"):
if sr % 1000 == 0: if sr % 1000 == 0: