From 1cdf07884f6652e974caa4f9eebd231568306ff9 Mon Sep 17 00:00:00 2001 From: Bazarr Date: Thu, 7 May 2020 13:07:34 +0100 Subject: [PATCH] simplified raise exceptions (raise_for_status() already raises exceptions --- libs/subliminal_patch/providers/legendasdivx.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/subliminal_patch/providers/legendasdivx.py b/libs/subliminal_patch/providers/legendasdivx.py index 77e1cd22a..fda404622 100644 --- a/libs/subliminal_patch/providers/legendasdivx.py +++ b/libs/subliminal_patch/providers/legendasdivx.py @@ -163,6 +163,11 @@ class LegendasdivxProvider(Provider): res = self.session.post(self.loginpage, data) res.raise_for_status() + if (res and 'bloqueado' in res.text.lower()): # blocked IP address + logger.error("LegendasDivx.pt :: Your IP is blocked on this server.") + raise ParseResponseError("Legendasdivx.pt :: %r" % res.text) + + #make sure we're logged in try: logger.debug('Logged in successfully: PHPSESSID: %s' % self.session.cookies.get_dict()['PHPSESSID']) @@ -171,9 +176,6 @@ class LegendasdivxProvider(Provider): logger.error("Couldn't retrieve session ID, check your credentials") raise AuthenticationError("Please check your credentials.") except Exception as e: - if (res and 'bloqueado' in res.text.lower()): # blocked IP address - logger.error("LegendasDivx.pt :: Your IP is blocked on this server.") - raise ParseResponseError("Legendasdivx.pt :: %r" % res.text) logger.error("LegendasDivx.pt :: Uncaught error: %r" % repr(e)) raise ServiceUnavailable("LegendasDivx.pt :: Uncaught error: %r" % repr(e)) @@ -305,8 +307,10 @@ class LegendasdivxProvider(Provider): res.raise_for_status() if res: if 'limite' in res.text.lower(): # daily downloads limit reached - raise DownloadLimitReached("Legendasdivx.pt :: Download limit reached") + logger.error("LegendasDivx.pt :: Daily download limit reached!") + raise DownloadLimitReached("Legendasdivx.pt :: Daily download limit reached!") elif 'bloqueado' in res.text.lower(): # blocked IP address + logger.error("LegendasDivx.pt :: Your IP is blocked on this server.") raise ParseResponseError("Legendasdivx.pt :: %r" % res.text) archive = self._get_archive(res.content)