diff options
-rw-r--r-- | bazarr/get_subtitle/refiners/__init__.py | 7 | ||||
-rw-r--r-- | bazarr/get_subtitle/refiners/database.py | 2 | ||||
-rw-r--r-- | bazarr/get_subtitle/refiners/utils.py | 9 | ||||
-rw-r--r-- | bazarr/get_subtitle/utils.py | 26 |
4 files changed, 24 insertions, 20 deletions
diff --git a/bazarr/get_subtitle/refiners/__init__.py b/bazarr/get_subtitle/refiners/__init__.py index 10f081193..e4bbba618 100644 --- a/bazarr/get_subtitle/refiners/__init__.py +++ b/bazarr/get_subtitle/refiners/__init__.py @@ -1,2 +1,5 @@ -from .database import refine_from_db # noqa: W0611 -from .ffprobe import refine_from_ffprobe # noqa: W0611 +# -*- coding: utf-8 -*- +from .ffprobe import refine_from_ffprobe +from .database import refine_from_db + +registered = {"database": refine_from_db, "ffprobe": refine_from_ffprobe} diff --git a/bazarr/get_subtitle/refiners/database.py b/bazarr/get_subtitle/refiners/database.py index cab974738..b8d02f28a 100644 --- a/bazarr/get_subtitle/refiners/database.py +++ b/bazarr/get_subtitle/refiners/database.py @@ -8,7 +8,7 @@ from subliminal import Episode, Movie from helper import path_mappings from database import TableShows, TableEpisodes, TableMovies -from ..utils import convert_to_guessit +from .utils import convert_to_guessit def refine_from_db(path, video): diff --git a/bazarr/get_subtitle/refiners/utils.py b/bazarr/get_subtitle/refiners/utils.py new file mode 100644 index 000000000..3df803e19 --- /dev/null +++ b/bazarr/get_subtitle/refiners/utils.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- + +from guessit import guessit + +def convert_to_guessit(guessit_key, attr_from_db): + try: + return guessit(attr_from_db)[guessit_key] + except KeyError: + return attr_from_db diff --git a/bazarr/get_subtitle/utils.py b/bazarr/get_subtitle/utils.py index 76ae955bf..49a862cd9 100644 --- a/bazarr/get_subtitle/utils.py +++ b/bazarr/get_subtitle/utils.py @@ -1,18 +1,18 @@ # coding=utf-8 # fmt: off -import os import logging -import copy +import os from subzero.language import Language from subzero.video import parse_video -from guessit import guessit from custom_lang import CustomLanguage from database import get_profiles_list from score import movie_score, series_score +from .refiners import registered as registered_refiners + def get_video(path, title, sceneName, providers=None, media_type="movie"): """ @@ -42,23 +42,15 @@ def get_video(path, title, sceneName, providers=None, media_type="movie"): video.original_name = original_name video.original_path = original_path - from get_subtitle.refiners import refine_from_db - refine_from_db(original_path, video) - from get_subtitle.refiners import refine_from_ffprobe - refine_from_ffprobe(original_path, video) + for key, refiner in registered_refiners.items(): + logging.debug("Running refiner: %s", key) + refiner(original_path, video) - logging.debug('BAZARR is using these video object properties: %s', vars(copy.deepcopy(video))) + logging.debug('BAZARR is using these video object properties: %s', vars(video)) return video - except Exception: - logging.exception("BAZARR Error trying to get video information for this file: " + original_path) - - -def convert_to_guessit(guessit_key, attr_from_db): - try: - return guessit(attr_from_db)[guessit_key] - except KeyError: - return attr_from_db + except Exception as error: + logging.exception("BAZARR Error (%s) trying to get video information for this file: %s", error, original_path) def _get_download_code3(subtitle): |