feat(analyzer): override paths using env variables

Allow overriding FFMPEG, FFPROBE, or LIQUIDSOAP paths using env variables.
This commit is contained in:
jo 2022-08-09 15:54:58 +02:00 committed by Kyle Robbertze
parent 9413bd5a29
commit 04e5a7e404
4 changed files with 14 additions and 7 deletions

View File

@ -1,14 +1,18 @@
import re
from math import inf
from os import getenv
from pathlib import Path
from typing import List, Optional, Tuple
from ._utils import run_
FFPROBE = getenv("FFPROBE_PATH", "ffprobe")
FFMPEG = getenv("FFMPEG_PATH", "ffmpeg")
def _ffmpeg(*args, **kwargs):
return run_(
"ffmpeg",
FFMPEG,
*args,
"-f",
"null",
@ -20,7 +24,7 @@ def _ffmpeg(*args, **kwargs):
def _ffprobe(*args, **kwargs):
return run_("ffprobe", *args, **kwargs)
return run_(FFPROBE, *args, **kwargs)
_PROBE_REPLAYGAIN_RE = re.compile(

View File

@ -0,0 +1,4 @@
from os import getenv
LIQUIDSOAP = getenv("LIQUIDSOAP_PATH", "liquidsoap")

View File

@ -5,14 +5,13 @@ from typing import Any, Dict
from loguru import logger
from ._liquidsoap import LIQUIDSOAP
class UnplayableFileError(Exception):
pass
LIQUIDSOAP_EXECUTABLE = "liquidsoap"
def analyze_playability(filename: str, metadata: Dict[str, Any]):
"""Checks if a file can be played by Liquidsoap.
:param filename: The full path to the file to analyzer
@ -20,7 +19,7 @@ def analyze_playability(filename: str, metadata: Dict[str, Any]):
:return: The metadata dictionary
"""
command = [
LIQUIDSOAP_EXECUTABLE,
LIQUIDSOAP,
"-v",
"-c",
"output.dummy(audio_to_stereo(single(argv(1))))",

View File

@ -21,7 +21,7 @@ def test_analyze_playability(filepath):
def test_analyze_playability_missing_liquidsoap():
with patch(
"libretime_analyzer.pipeline.analyze_playability.LIQUIDSOAP_EXECUTABLE",
"libretime_analyzer.pipeline._liquidsoap.LIQUIDSOAP",
"foobar",
):
analyze_playability(str(FILES[0].path), {})