From 718bd2f8b9b5ed470379381cb51773a3ddc9944f Mon Sep 17 00:00:00 2001 From: Vitiko Date: Mon, 13 Dec 2021 15:41:46 -0400 Subject: [PATCH] Add default attribute to Subtitle --- libs/subliminal/subtitle.py | 2 ++ libs/subliminal_patch/core.py | 19 +++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libs/subliminal/subtitle.py b/libs/subliminal/subtitle.py index 792df1a1c..2f30f43da 100644 --- a/libs/subliminal/subtitle.py +++ b/libs/subliminal/subtitle.py @@ -50,6 +50,8 @@ class Subtitle(object): #: Encoding to decode with when accessing :attr:`text` self.encoding = None + self.release_info = None + # validate the encoding if encoding: try: diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index aa82db1f9..f4605b1eb 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -187,16 +187,15 @@ class SZProviderPool(ProviderPool): if (str(provider), str(s.id)) in self.blacklist: logger.info("Skipping blacklisted subtitle: %s", s) continue - if hasattr(s, 'release_info'): - if s.release_info is not None: - if any([x for x in self.ban_list["must_not_contain"] - if re.search(x, s.release_info, flags=re.IGNORECASE) is not None]): - logger.info("Skipping subtitle because release name contains prohibited string: %s", s) - continue - if any([x for x in self.ban_list["must_contain"] - if re.search(x, s.release_info, flags=re.IGNORECASE) is None]): - logger.info("Skipping subtitle because release name does not contains required string: %s", s) - continue + if s.release_info is not None: + if any([x for x in self.ban_list["must_not_contain"] + if re.search(x, s.release_info, flags=re.IGNORECASE) is not None]): + logger.info("Skipping subtitle because release name contains prohibited string: %s", s) + continue + if any([x for x in self.ban_list["must_contain"] + if re.search(x, s.release_info, flags=re.IGNORECASE) is None]): + logger.info("Skipping subtitle because release name does not contains required string: %s", s) + continue if s.id in seen: continue s.plex_media_fps = float(video.fps) if video.fps else None