diff --git a/libs/subliminal_patch/http.py b/libs/subliminal_patch/http.py index 6073a73f9..8683c6eda 100644 --- a/libs/subliminal_patch/http.py +++ b/libs/subliminal_patch/http.py @@ -86,6 +86,7 @@ class CFSession(CloudflareScraper, CertifiSession, TimeoutSession): self.headers['User-Agent'] = user_agent ret = super(CFSession, self).request(method, url, *args, **kwargs) + try: cf_data = self.get_live_tokens(domain) except: diff --git a/libs/subliminal_patch/providers/subscene.py b/libs/subliminal_patch/providers/subscene.py index d6a294cdb..7f2758b14 100644 --- a/libs/subliminal_patch/providers/subscene.py +++ b/libs/subliminal_patch/providers/subscene.py @@ -200,23 +200,23 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin): def query(self, video): vfn = get_video_filename(video) subtitles = [] - logger.debug(u"Searching for: %s", vfn) - film = search(vfn, session=self.session) + #logger.debug(u"Searching for: %s", vfn) + # film = search(vfn, session=self.session) + # + # if film and film.subtitles: + # logger.debug('Release results found: %s', len(film.subtitles)) + # subtitles = self.parse_results(video, film) + # else: + # logger.debug('No release results found') - if film and film.subtitles: - logger.debug('Release results found: %s', len(film.subtitles)) - subtitles = self.parse_results(video, film) - else: - logger.debug('No release results found') - - time.sleep(self.search_throttle) + #time.sleep(self.search_throttle) # re-search for episodes without explicit release name if isinstance(video, Episode): #term = u"%s S%02iE%02i" % (video.series, video.season, video.episode) + more_than_one = len([video.series] + video.alternative_series) > 1 for series in [video.series] + video.alternative_series: term = u"%s - %s Season" % (series, p.number_to_words("%sth" % video.season).capitalize()) - time.sleep(self.search_throttle) logger.debug('Searching for alternative results: %s', term) film = search(term, session=self.session, release=False) if film and film.subtitles: @@ -238,12 +238,17 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin): 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: + more_than_one = len([video.title] + video.alternative_titles) > 1 for title in [video.title] + video.alternative_titles: logger.debug('Searching for movie results: %s', title) film = search(title, year=video.year, session=self.session, limit_to=None, release=False) if film and film.subtitles: subtitles += self.parse_results(video, film) + if more_than_one: + time.sleep(self.search_throttle) logger.info("%s subtitles found" % len(subtitles)) return subtitles diff --git a/libs/subliminal_patch/refiners/util.py b/libs/subliminal_patch/refiners/util.py new file mode 100644 index 000000000..f83701684 --- /dev/null +++ b/libs/subliminal_patch/refiners/util.py @@ -0,0 +1,10 @@ +# coding=utf-8 + +import types +from subliminal_patch.http import TimeoutSession + + +def fix_session_bases(obj): + obj.__class__ = type("PatchedTimeoutSession", (TimeoutSession,), + {"request": types.MethodType(TimeoutSession.request, obj)}) + return obj