fix(ui): use default audio icon if ffmpeg is absent (#471)

* fix(ThumbRenderer): Use audio icon when no ffmpeg

When ffmpeg is missing, Popen raises a FileNotFound error. This would
be caught as an Unlinked file and use the broken file icon. The
exception is now caught and a more appropriate exception is raised in
its place.

* ruff formatting
This commit is contained in:
Sean Krueger
2024-09-07 20:24:10 -07:00
committed by GitHub
parent 8c9b04d1ec
commit bf8816f715
2 changed files with 13 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
# type: ignore
# Copyright (C) 2022 James Robert (jiaaro).
# Licensed under the MIT License.
# Vendored from ffmpeg-python and ffmpeg-python PR#790 by amamic1803
# Vendored from pydub
from __future__ import division
@@ -729,7 +729,10 @@ class _AudioSegment(object):
info = None
else:
# PATCHED
info = _mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
try:
info = _mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
except FileNotFoundError:
raise ChildProcessError
if info:
audio_streams = [x for x in info['streams']
if x['codec_type'] == 'audio']
@@ -1400,4 +1403,4 @@ class _AudioSegment(object):
"""
fh = self.export()
data = base64.b64encode(fh.read()).decode('ascii')
return src.format(base64=data)
return src.format(base64=data)

View File

@@ -565,6 +565,7 @@ class ThumbRenderer(QObject):
logging.error(
f"[ThumbRenderer][WAVEFORM][ERROR]: Couldn't render waveform for {filepath.name} ({type(e).__name__})"
)
return im
def _blender(self, filepath: Path) -> Image.Image:
@@ -1057,7 +1058,12 @@ class ThumbRenderer(QObject):
size=(adj_size, adj_size),
pixel_ratio=pixel_ratio,
)
except (UnidentifiedImageError, DecompressionBombError, ValueError) as e:
except (
UnidentifiedImageError,
DecompressionBombError,
ValueError,
ChildProcessError,
) as e:
logging.info(
f"[ThumbRenderer][ERROR]: Couldn't render thumbnail for {_filepath.name} ({type(e).__name__})"
)