mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 07:39:10 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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__})"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user