diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index 0905ce1df..097457ce3 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -309,7 +309,8 @@ class SZProviderPool(ProviderPool): logger.error('Invalid subtitle') return False - subtitle.normalize() + if not os.environ.get("SZ_KEEP_ENCODING", False): + subtitle.normalize() return True diff --git a/libs/subliminal_patch/providers/subscene.py b/libs/subliminal_patch/providers/subscene.py index b940eb787..098447ad5 100644 --- a/libs/subliminal_patch/providers/subscene.py +++ b/libs/subliminal_patch/providers/subscene.py @@ -190,7 +190,7 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin): return subtitles def query(self, video): - vfn = get_video_filename(video) + #vfn = get_video_filename(video) subtitles = [] #logger.debug(u"Searching for: %s", vfn) # film = search(vfn, session=self.session) @@ -218,18 +218,18 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin): logger.debug('No alternative results found') # packs - if video.season_fully_aired: - term = u"%s S%02i" % (series, video.season) - logger.debug('Searching for packs: %s', term) - time.sleep(self.search_throttle) - film = search(term, session=self.session, throttle=self.search_throttle) - if film and film.subtitles: - logger.debug('Pack results found: %s', len(film.subtitles)) - subtitles += self.parse_results(video, film) - else: - logger.debug('No pack results found') - else: - logger.debug("Not searching for packs, because the season hasn't fully aired") + # if video.season_fully_aired: + # term = u"%s S%02i" % (series, video.season) + # logger.debug('Searching for packs: %s', term) + # time.sleep(self.search_throttle) + # film = search(term, session=self.session, throttle=self.search_throttle) + # if film and film.subtitles: + # logger.debug('Pack results found: %s', len(film.subtitles)) + # subtitles += self.parse_results(video, film) + # else: + # logger.debug('No pack results found') + # else: + # logger.debug("Not searching for packs, because the season hasn't fully aired") if more_than_one: time.sleep(self.search_throttle) else: diff --git a/libs/subliminal_patch/subtitle.py b/libs/subliminal_patch/subtitle.py index ea89d901a..6b2263e59 100644 --- a/libs/subliminal_patch/subtitle.py +++ b/libs/subliminal_patch/subtitle.py @@ -251,8 +251,7 @@ class Subtitle(Subtitle_): subs = pysubs2.SSAFile.from_string(text, fps=self.plex_media_fps) unicontent = self.pysubs2_to_unicode(subs) - self.content = unicontent.encode("utf-8") - self._guessed_encoding = "utf-8" + self.content = unicontent.encode(self._guessed_encoding) except: logger.exception("Couldn't convert subtitle %s to .srt format: %s", self, traceback.format_exc()) return False @@ -320,7 +319,8 @@ class Subtitle(Subtitle_): :return: string """ if not self.mods: - return fix_text(self.content.decode("utf-8"), **ftfy_defaults).encode(encoding="utf-8") + return fix_text(self.content.decode(encoding=self._guessed_encoding), **ftfy_defaults).encode( + encoding=self._guessed_encoding) submods = SubtitleModifications(debug=debug) if submods.load(content=self.text, language=self.language): @@ -329,7 +329,7 @@ class Subtitle(Subtitle_): self.mods = submods.mods_used content = fix_text(self.pysubs2_to_unicode(submods.f, format=format), **ftfy_defaults)\ - .encode(encoding="utf-8") + .encode(encoding=self._guessed_encoding) submods.f = None del submods return content diff --git a/libs/subscene_api/subscene.py b/libs/subscene_api/subscene.py index e0ba77138..c8450518a 100644 --- a/libs/subscene_api/subscene.py +++ b/libs/subscene_api/subscene.py @@ -263,7 +263,7 @@ def search(term, release=True, session=None, year=None, limit_to=SearchTypes.Exa time.sleep(throttle) # fixme: detect endpoint from html continue - raise + return break if soup: