FFMPEGProxy.__call__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
import json
2
import logging
3
from typing import Any, Protocol
4
5
from software_patterns import Proxy
6
7
__all__ = ['FFProbeProxy']
8
9
10
logger = logging.getLogger(__name__)
11
12
13
class CLIResult(Protocol):
14
    exit_code: int
15
    stdout: str
16
    stderr: str
17
18
19
class FFMpegSubjectType(Protocol):
20
    def __init__(self, ffmpeg_binary: str):
21
        ...
22
23
    def __call__(self, *ffmpeg_cli_args, **subprocess_settings) -> CLIResult:
24
        ...
25
26
27
class FFMPEGProxy(Proxy[FFMpegSubjectType]):
28
    """Proxy class for the ffmpeg CLI."""
29
30
    def __call__(self, *ffmpeg_cli_args: str, **subprocess_settings: Any) -> CLIResult:
31
        logger.error(
32
            "Running ffmpeg: %s", json.dumps(list(ffmpeg_cli_args), indent=4, sort_keys=True)
33
        )
34
        res = self._proxy_subject(*ffmpeg_cli_args, **subprocess_settings)
35
        # logger.info("FFMPEG:\n%s", res.stderr)
36
        return res
37