mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Optional parameter to check if the encoder exists
If `must_exists` is `False` when intializing `EncoderFFmpeg()`, skip skip checking whether the FFmpeg binary exists. Fixes #722.
This commit is contained in:
@@ -37,12 +37,12 @@ class EncoderBase(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, encoder_path, loglevel, additional_arguments=[]):
|
||||
def __init__(self, encoder_path, must_exist, loglevel, additional_arguments=[]):
|
||||
"""
|
||||
This method must make sure whether specified encoder
|
||||
is available under PATH.
|
||||
"""
|
||||
if shutil.which(encoder_path) is None:
|
||||
if must_exist and shutil.which(encoder_path) is None:
|
||||
raise EncoderNotFoundError(
|
||||
"{} executable does not exist or was not found in PATH.".format(
|
||||
encoder_path
|
||||
|
||||
@@ -27,11 +27,11 @@ RULES = {
|
||||
|
||||
|
||||
class EncoderFFmpeg(EncoderBase):
|
||||
def __init__(self, encoder_path="ffmpeg"):
|
||||
def __init__(self, encoder_path="ffmpeg", must_exist=True):
|
||||
_loglevel = "-hide_banner -nostats -v panic"
|
||||
_additional_arguments = ["-b:a", "192k", "-vn"]
|
||||
try:
|
||||
super().__init__(encoder_path, _loglevel, _additional_arguments)
|
||||
super().__init__(encoder_path, must_exist, _loglevel, _additional_arguments)
|
||||
except EncoderNotFoundError as e:
|
||||
raise FFmpegNotFoundError(e.args[0])
|
||||
self._rules = RULES
|
||||
|
||||
Reference in New Issue
Block a user