static_ffmpeg icon indicating copy to clipboard operation
static_ffmpeg copied to clipboard

add_path with weak=True will always return False

Open Billuc opened this issue 2 years ago • 1 comments

Hi,

I just discovered this tool and I started using it on my project, but I couldn't get it to work in the first place. I wanted to install ffmpeg, but only if it wasn't, so I set the weak flag to True. The result I got from the add_paths method was always False.

By looking up in the code, I understood why. This part in the code is responsible for this behaviour :

    if weak:
        has_ffmpeg = _has("ffmpeg") is not None
        has_ffprobe = _has("ffprobe") is not None
        if has_ffmpeg and has_ffprobe:
            return False

_has returns a boolean value, but is compared to None. This will always return True !

>>> True is not None # True
>>> False is not None # True

Thus, the method will always return False, even though ffmpeg isn't installed !

Billuc avatar Jul 22 '23 13:07 Billuc

Ran into this issue too. #12 is definitely the fix for it.

In the meanwhile, I'm just doing a manual check.

if shutil.which("ffmpeg") is None or shutil.which("ffprobe") is None:
    print("Loading ffmpeg")
    static_ffmpeg.add_paths()

FlippFuzz avatar Oct 25 '23 12:10 FlippFuzz