diff --git a/src/music_kraken/audio/codec.py b/src/music_kraken/audio/codec.py index 42518a9..91beef1 100644 --- a/src/music_kraken/audio/codec.py +++ b/src/music_kraken/audio/codec.py @@ -1,9 +1,8 @@ from typing import List, Tuple from tqdm import tqdm from ffmpeg_progress_yield import FfmpegProgress -import subprocess -from ..utils.shared import BITRATE, AUDIO_FORMAT, CODEX_LOGGER as LOGGER +from ..utils.shared import BITRATE, AUDIO_FORMAT, CODEX_LOGGER as LOGGER, FFMPEG_BINARY from ..objects import Target @@ -36,7 +35,7 @@ def correct_codec(target: Target, bitrate_kb: int = BITRATE, audio_format: str = # build the ffmpeg command ffmpeg_command = [ - "ffmpeg", + str(FFMPEG_BINARY), "-i", str(target.file_path), "-af", select, "-b", str(bitrate_b), diff --git a/src/music_kraken/cli/informations/paths.py b/src/music_kraken/cli/informations/paths.py index cb1ba98..4db50dd 100644 --- a/src/music_kraken/cli/informations/paths.py +++ b/src/music_kraken/cli/informations/paths.py @@ -10,7 +10,8 @@ def all_paths(): "Music dir": LOCATIONS.MUSIC_DIRECTORY, "Log file": shared.LOG_PATH, "Conf dir": LOCATIONS.CONFIG_DIRECTORY, - "Conf file": LOCATIONS.CONFIG_FILE + "Conf file": LOCATIONS.CONFIG_FILE, + "FFMPEG bin": LOCATIONS.FFMPEG_BIN, } diff --git a/src/music_kraken/utils/config/paths.py b/src/music_kraken/utils/config/paths.py index 32e781c..18cc839 100644 --- a/src/music_kraken/utils/config/paths.py +++ b/src/music_kraken/utils/config/paths.py @@ -38,12 +38,19 @@ class PathsSection(Section): r'^\.' # is hidden/starts with a "." ] ) + + self.FFMPEG_BINARY = PathAttribute( + name="ffmpeg_binary", + description="Set the path to the ffmpeg binary.", + value=str(LOCATIONS.FFMPEG_BIN) + ) self.attribute_list = [ self.MUSIC_DIRECTORY, self.TEMP_DIRECTORY, self.LOG_PATH, - self.NOT_A_GENRE_REGEX + self.NOT_A_GENRE_REGEX, + self.FFMPEG_BINARY ] super().__init__() diff --git a/src/music_kraken/utils/path_manager/locations.py b/src/music_kraken/utils/path_manager/locations.py index 7f7c754..072c65e 100644 --- a/src/music_kraken/utils/path_manager/locations.py +++ b/src/music_kraken/utils/path_manager/locations.py @@ -2,6 +2,7 @@ from pathlib import Path import os import tempfile +from pyffmpeg import FFmpeg from .music_directory import get_music_directory from .config_directory import get_config_directory @@ -19,6 +20,8 @@ class Locations: self.CONFIG_DIRECTORY = get_config_directory(str(application_name)) self.CONFIG_DIRECTORY.mkdir(exist_ok=True, parents=True) self.CONFIG_FILE = Path(self.CONFIG_DIRECTORY, f"{application_name}.conf") + + self.FFMPEG_BIN = Path(FFmpeg(enable_log=False).get_ffmpeg_bin()) def get_log_file(self, file_name: os.PathLike) -> Path: return Path(self.TEMP_DIRECTORY, file_name) diff --git a/src/music_kraken/utils/shared.py b/src/music_kraken/utils/shared.py index bceba4a..99b47e9 100644 --- a/src/music_kraken/utils/shared.py +++ b/src/music_kraken/utils/shared.py @@ -120,3 +120,5 @@ to download: have fun :3 """.strip() + +FFMPEG_BINARY: Path = PATHS_SECTION.FFMPEG_BINARY.object_from_value