error when password is invalid or when user is banned
This commit is contained in:
parent
0985ab7062
commit
0e5089c2c0
2 changed files with 13 additions and 3 deletions
|
|
@ -40,7 +40,7 @@ class GazelleBrowser(BaseBrowser):
|
|||
|
||||
def login(self):
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.home()
|
||||
self.location('/login.php', no_login=True)
|
||||
self.page.login(self.username, self.password)
|
||||
|
||||
def is_logged(self):
|
||||
|
|
@ -51,7 +51,7 @@ class GazelleBrowser(BaseBrowser):
|
|||
return True
|
||||
|
||||
def home(self):
|
||||
return self.location('%s://%s/login.php' % (self.PROTOCOL, self.DOMAIN))
|
||||
return self.location('%s://%s/' % (self.PROTOCOL, self.DOMAIN))
|
||||
|
||||
def iter_torrents(self, pattern):
|
||||
self.location(self.buildurl('/torrents.php', searchstr=pattern.encode('utf-8')))
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
from weboob.tools.browser import BasePage, BrowserIncorrectPassword, BrowserBanned
|
||||
from weboob.tools.misc import remove_html_tags
|
||||
|
||||
|
||||
__all__ = ['IndexPage', 'LoginPage']
|
||||
|
|
@ -30,6 +31,15 @@ class IndexPage(BasePage):
|
|||
|
||||
|
||||
class LoginPage(BasePage):
|
||||
def on_loaded(self):
|
||||
warns = self.parser.select(self.document.getroot(), 'span.warning')
|
||||
for warn in warns:
|
||||
text = remove_html_tags(self.parser.tostring(warn)).strip()
|
||||
if text.startswith('Your username'):
|
||||
raise BrowserIncorrectPassword(text)
|
||||
if text.startswith('You are banned'):
|
||||
raise BrowserBanned(text)
|
||||
|
||||
def login(self, login, password):
|
||||
self.browser.select_form(nr=0)
|
||||
self.browser['username'] = login
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue