Some AUM fixups

This commit is contained in:
Roger Philibert 2011-04-13 12:43:26 +02:00 committed by Romain Bignon
commit 7a0aad5e8f
3 changed files with 14 additions and 4 deletions

View file

@ -68,6 +68,7 @@ class AuMBrowser(BaseBrowser):
'http://www.adopteunmec.com/register4.php.*': RegisterConfirmPage, 'http://www.adopteunmec.com/register4.php.*': RegisterConfirmPage,
'http://www.adopteunmec.com/home.php': HomePage, 'http://www.adopteunmec.com/home.php': HomePage,
'http://www.adopteunmec.com/shop2c?.php': ShopPage, 'http://www.adopteunmec.com/shop2c?.php': ShopPage,
'http[s]://www.adopteunmec.com/register-pay.php': ShopPage,
'http://www.adopteunmec.com/mails.php': ContactListPage, 'http://www.adopteunmec.com/mails.php': ContactListPage,
'http://www.adopteunmec.com/mail.php': ContactListPage, 'http://www.adopteunmec.com/mail.php': ContactListPage,
'http://www.adopteunmec.com/mails.php\?type=1': BasketsPage, 'http://www.adopteunmec.com/mails.php\?type=1': BasketsPage,
@ -105,7 +106,7 @@ class AuMBrowser(BaseBrowser):
return not self.is_on_page(LoginPage) return not self.is_on_page(LoginPage)
def home(self): def home(self):
return self.location('http://www.adopteunmec.com/home.php') return self.location('http://www.adopteunmec.com/')
def pageaccess(func): def pageaccess(func):
def inner(self, *args, **kwargs): def inner(self, *args, **kwargs):
@ -273,7 +274,7 @@ class AuMBrowser(BaseBrowser):
@pageaccess @pageaccess
def search_profiles(self, **kwargs): def search_profiles(self, **kwargs):
self.location('/search.php?display=1') self.location('/search.php')
self.page.search(**kwargs) self.page.search(**kwargs)
return self.page.get_profiles_ids() return self.page.get_profiles_ids()

View file

@ -22,6 +22,7 @@ from __future__ import with_statement
from weboob.tools.browser import BrowserUnavailable from weboob.tools.browser import BrowserUnavailable
from weboob.capabilities.dating import Optimization from weboob.capabilities.dating import Optimization
from weboob.capabilities.contact import QueryError
from weboob.tools.log import getLogger from weboob.tools.log import getLogger
@ -56,6 +57,9 @@ class QueriesQueue(Optimization):
return self.check_cron is not None return self.check_cron is not None
def enqueue_query(self, id, priority=999): def enqueue_query(self, id, priority=999):
id_queue = [_id[1] for _id in self.queue]
if int(id) in id_queue:
raise QueryError('This id is already queued')
self.queue.append((int(priority), int(id))) self.queue.append((int(priority), int(id)))
self.save() self.save()
# Try to flush queue to send it now. # Try to flush queue to send it now.

View file

@ -19,6 +19,7 @@
import re import re
import mechanize
from weboob.tools.mech import ClientForm from weboob.tools.mech import ClientForm
from weboob.tools.browser import BrowserIncorrectPassword from weboob.tools.browser import BrowserIncorrectPassword
@ -30,7 +31,10 @@ from ..captcha import Captcha
class LoginPage(PageBase): class LoginPage(PageBase):
def login(self, login, password): def login(self, login, password):
try:
self.browser.select_form(name="form_login") self.browser.select_form(name="form_login")
except mechanize._mechanize.FormNotFoundError:
return
self.browser['login'] = login self.browser['login'] = login
self.browser['password'] = password self.browser['password'] = password
@ -120,7 +124,8 @@ class BanPage(PageBase):
raise AdopteBanned('Your IP address is banned.') raise AdopteBanned('Your IP address is banned.')
class ShopPage(PageBase): class ShopPage(PageBase):
pass def on_loaded(self):
self.browser.location('http://www.adopteunmec.com/account.php')
class ErrPage(PageBase): class ErrPage(PageBase):
def on_loaded(self): def on_loaded(self):