From 0970f19d96443401b92099ceaa1e8b654258b077 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Wed, 21 Dec 2022 19:30:59 -0500 Subject: [PATCH] Fixed mediainfo integration issues. #2007 --- bazarr/subtitles/refiners/ffprobe.py | 7 +++++-- bazarr/subtitles/tools/embedded_subs_reader.py | 16 ++++++++++++---- frontend/src/pages/Settings/Scheduler/index.tsx | 13 +++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/bazarr/subtitles/refiners/ffprobe.py b/bazarr/subtitles/refiners/ffprobe.py index f0e1ce0bd..9751814e6 100644 --- a/bazarr/subtitles/refiners/ffprobe.py +++ b/bazarr/subtitles/refiners/ffprobe.py @@ -32,8 +32,8 @@ def refine_from_ffprobe(path, video): data = parse_video_metadata(file=path, file_size=file_id['file_size'], episode_file_id=file_id['episode_file_id']) - if not data['ffprobe'] or data['mediainfo']: - logging.debug("No FFprobe available in cache for this file: {}".format(path)) + if not any([data['ffprobe'], data['mediainfo'], data['enzyme']]): + logging.error("No cache available for this file: {}".format(path)) return video if data['ffprobe']: @@ -42,6 +42,9 @@ def refine_from_ffprobe(path, video): elif data['mediainfo']: logging.debug('Mediainfo found: %s', data['mediainfo']) parser_data = data['mediainfo'] + elif data['enzyme']: + logging.debug('Enzyme found: %s', data['enzyme']) + parser_data = data['enzyme'] else: parser_data = {} diff --git a/bazarr/subtitles/tools/embedded_subs_reader.py b/bazarr/subtitles/tools/embedded_subs_reader.py index 99c8490f6..94860ffb7 100644 --- a/bazarr/subtitles/tools/embedded_subs_reader.py +++ b/bazarr/subtitles/tools/embedded_subs_reader.py @@ -93,6 +93,8 @@ def parse_video_metadata(file, file_size, episode_file_id=None, movie_file_id=No "file_size": file_size, } + embedded_subs_parser = settings.general.embedded_subtitles_parser + if use_cache: # Get the actual cache value form database if episode_file_id: @@ -115,17 +117,23 @@ def parse_video_metadata(file, file_size, episode_file_id=None, movie_file_id=No except Exception: pass else: - # Check if file size and file id matches and if so, we return the cached value + # Check if file size and file id matches and if so, we return the cached value if available for the + # desired parser if cached_value['file_size'] == file_size and cached_value['file_id'] in [episode_file_id, movie_file_id]: - return cached_value + if ((embedded_subs_parser == 'ffprobe' and 'ffprobe' in cached_value and cached_value['ffprobe']) or + (embedded_subs_parser == 'mediainfo' and 'mediainfo' in cached_value and + cached_value['mediainfo']) or + (all(['ffprobe', 'mediainfo']) not in cached_value and 'enzyme' in cached_value and + cached_value['enzyme'])): + return cached_value # if not, we retrieve the metadata from the file from utilities.binaries import get_binary ffprobe_path = mediainfo_path = None - if settings.general.embedded_subtitles_parser == 'ffprobe': + if embedded_subs_parser == 'ffprobe': ffprobe_path = get_binary("ffprobe") - elif settings.general.embedded_subtitles_parser == 'mediainfo': + elif embedded_subs_parser == 'mediainfo': mediainfo_path = get_binary("mediainfo") # if we have ffprobe available diff --git a/frontend/src/pages/Settings/Scheduler/index.tsx b/frontend/src/pages/Settings/Scheduler/index.tsx index c885f6854..e2a236197 100644 --- a/frontend/src/pages/Settings/Scheduler/index.tsx +++ b/frontend/src/pages/Settings/Scheduler/index.tsx @@ -78,12 +78,13 @@ const SettingsSchedulerView: FunctionComponent = () => { - If disabled, Bazarr will use ffprobe to index video file properties on - each run. This will result in higher disk I/O. + If disabled, Bazarr will use the embedded subtitles parser to index + episodes file properties on each run. This will result in higher disk + I/O. { - If disabled, Bazarr will use ffprobe to index video file properties on - each run. This will result in higher disk I/O. + If disabled, Bazarr will use embedded subtitles parser to index movies + file properties on each run. This will result in higher disk I/O.