From b1d2689cbaefc92f1db5850f9d37b4ef48e43143 Mon Sep 17 00:00:00 2001 From: panni Date: Thu, 29 Nov 2018 12:36:17 +0100 Subject: [PATCH] update to latest subliminal_patch; fixes podnapisi search for Marvel series --- .../subliminal_patch/providers/hosszupuska.py | 2 +- libs/subliminal_patch/providers/podnapisi.py | 23 ++++++++++++++++--- libs/subliminal_patch/utils.py | 1 - 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/libs/subliminal_patch/providers/hosszupuska.py b/libs/subliminal_patch/providers/hosszupuska.py index 96c5bce71..186fb06d7 100644 --- a/libs/subliminal_patch/providers/hosszupuska.py +++ b/libs/subliminal_patch/providers/hosszupuska.py @@ -35,7 +35,7 @@ def fix_inconsistent_naming(title): """ return _fix_inconsistent_naming(title, {"Stargate Origins": "Stargate: Origins", "Marvel's Agents of S.H.I.E.L.D.": "Marvels+Agents+of+S.H.I.E.L.D", - "Mayans M.C.": "Mayans MC"}, True ) + "Mayans M.C.": "Mayans MC"}, True) logger = logging.getLogger(__name__) diff --git a/libs/subliminal_patch/providers/podnapisi.py b/libs/subliminal_patch/providers/podnapisi.py index f55d08429..409a6708c 100644 --- a/libs/subliminal_patch/providers/podnapisi.py +++ b/libs/subliminal_patch/providers/podnapisi.py @@ -24,11 +24,28 @@ from subliminal import Episode from subliminal import Movie from subliminal.providers.podnapisi import PodnapisiProvider as _PodnapisiProvider, \ PodnapisiSubtitle as _PodnapisiSubtitle +from subliminal_patch.utils import sanitize, fix_inconsistent_naming as _fix_inconsistent_naming from subzero.language import Language logger = logging.getLogger(__name__) +def fix_inconsistent_naming(title): + """Fix titles with inconsistent naming using dictionary and sanitize them. + + :param str title: original title. + :return: new title. + :rtype: str + + """ + d = {} + nt = title.replace("Marvels", "").replace("Marvel's", "") + if nt != title: + d[title] = nt + + return _fix_inconsistent_naming(title, d) + + class PodnapisiSubtitle(_PodnapisiSubtitle): provider_name = 'podnapisi' hearing_impaired_verifiable = True @@ -53,8 +70,8 @@ class PodnapisiSubtitle(_PodnapisiSubtitle): # episode if isinstance(video, Episode): # series - if video.series and (sanitize(self.title) in ( - sanitize(name) for name in [video.series] + video.alternative_series)): + if video.series and (fix_inconsistent_naming(self.title) in ( + fix_inconsistent_naming(name) for name in [video.series] + video.alternative_series)): matches.add('series') # year if video.original_series and self.year is None or video.year and video.year == self.year: @@ -113,7 +130,7 @@ class PodnapisiProvider(_PodnapisiProvider, ProviderSubtitleArchiveMixin): season = episode = None if isinstance(video, Episode): - titles = [video.series] + video.alternative_series + titles = [fix_inconsistent_naming(title) for title in [video.series] + video.alternative_series] season = video.season episode = video.episode else: diff --git a/libs/subliminal_patch/utils.py b/libs/subliminal_patch/utils.py index 17720334e..410b7a2be 100644 --- a/libs/subliminal_patch/utils.py +++ b/libs/subliminal_patch/utils.py @@ -60,4 +60,3 @@ def fix_inconsistent_naming(title, inconsistent_titles_dict=None, no_sanitize=Fa else: return sanitize(title) # return fixed and sanitized title - return title