From 28663a69379d99876547c652ee8e87416e8e6b90 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Tue, 18 Jan 2022 16:13:04 -0500 Subject: [PATCH] Fixed issue with unrecognized languages while indexing subtitles (mainly for those without a language code in filename). --- bazarr/list_subtitles.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index 044bf94f3..3c0f543cc 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -86,7 +86,10 @@ def store_subtitles(original_path, reversed_path, use_cache=True): logging.exception("BAZARR unable to index external subtitles.") else: for subtitle, language in subtitles.items(): - valid_language = alpha2_from_alpha3(language.alpha3) + valid_language = False + if language: + if hasattr(language, 'alpha3'): + valid_language = alpha2_from_alpha3(language.alpha3) if not valid_language: logging.debug(f'{language.alpha3} is an unsupported language code.') continue @@ -190,7 +193,10 @@ def store_subtitles_movie(original_path, reversed_path, use_cache=True): pass else: for subtitle, language in subtitles.items(): - valid_language = alpha2_from_alpha3(language.alpha3) + valid_language = False + if language: + if hasattr(language, 'alpha3'): + valid_language = alpha2_from_alpha3(language.alpha3) if not valid_language: logging.debug(f'{language.alpha3} is an unsupported language code.') continue