add sex, age and godfather keys to aum backend, for register
This commit is contained in:
parent
e64d4fc288
commit
a1e8a67225
3 changed files with 45 additions and 10 deletions
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
from __future__ import with_statement
|
||||
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
from dateutil import tz
|
||||
from logging import warning, debug
|
||||
|
||||
|
|
@ -50,6 +50,10 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
CONFIG = {'username': BaseBackend.ConfigField(description='Username on website'),
|
||||
'password': BaseBackend.ConfigField(description='Password of account', is_masked=True),
|
||||
'register': BaseBackend.ConfigField(description='Register as new account?', default=False),
|
||||
'sex': BaseBackend.ConfigField(description='Sex of new the account owner', default='m',
|
||||
choices=('m', 'f')),
|
||||
'age': BaseBackend.ConfigField(description='Age of new the account owner', default=25),
|
||||
'godfather': BaseBackend.ConfigField(description='Godfather of new the account owner', default=''),
|
||||
'antispam': BaseBackend.ConfigField(description='Enable anti-spam', default=False),
|
||||
}
|
||||
STORAGE = {'profiles_walker': {'viewed': []},
|
||||
|
|
@ -69,17 +73,18 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
def create_default_browser(self):
|
||||
if self.config['register']:
|
||||
browser = None
|
||||
birthday = datetime.datetime.now() - datetime.timedelta(int(self.config['age']) * 365)
|
||||
while not browser:
|
||||
try:
|
||||
browser = self.create_browser(self.config['username'])
|
||||
browser.register(password= self.config['password'],
|
||||
sex= 0,
|
||||
birthday_d= 1,
|
||||
birthday_m= 1,
|
||||
birthday_y= 1970,
|
||||
sex= 0 if self.config['sex'] == 'm' else 1,
|
||||
birthday_d= birthday.day,
|
||||
birthday_m= birthday.month,
|
||||
birthday_y= birthday.year,
|
||||
zipcode= 75001,
|
||||
country= 'fr',
|
||||
godfather= '')
|
||||
godfather= self.config['godfather'])
|
||||
except CaptchaError:
|
||||
debug('Unable to resolve captcha. Retrying...')
|
||||
browser = None
|
||||
|
|
@ -268,7 +273,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
def _get_slut(self, id):
|
||||
sluts = self.storage.get('sluts')
|
||||
if not sluts or not id in sluts:
|
||||
slut = {'lastmsg': datetime(1970,1,1),
|
||||
slut = {'lastmsg': datetime.datetime(1970,1,1),
|
||||
'msgstatus': ''}
|
||||
else:
|
||||
slut = self.storage.get('sluts', id)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ from weboob.tools.parsers.html5libparser import Html5libParser
|
|||
|
||||
from weboob.backends.aum.exceptions import AdopteWait
|
||||
|
||||
from weboob.backends.aum.pages.account import AccountPage
|
||||
from weboob.backends.aum.pages.home import HomePage
|
||||
from weboob.backends.aum.pages.contact_list import ContactListPage
|
||||
from weboob.backends.aum.pages.contact_thread import ContactThreadPage
|
||||
|
|
@ -74,6 +75,7 @@ class AuMBrowser(BaseBrowser):
|
|||
'http://www.adopteunmec.com/catalogue-hommes/(.*)/([0-9]+)': ProfilePage,
|
||||
'http://www.adopteunmec.com/view2.php': ProfilePage, # my own profile
|
||||
'http://www.adopteunmec.com/(\w+)': ProfilePage, # a custom profile url
|
||||
'http://www.adopteunmec.com/account.php': AccountPage,
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -104,11 +106,14 @@ class AuMBrowser(BaseBrowser):
|
|||
return func(self, *args, **kwargs)
|
||||
return inner
|
||||
|
||||
def register(self, password, sex, birthday_d, birthday_m, birthday_y, zipcode, country, godfather=''):
|
||||
def register(self, password, sex, birthday_d, birthday_m, birthday_y, zipcode, country, godfather=None):
|
||||
if not self.is_on_page(RegisterPage):
|
||||
self.location('http://www.adopteunmec.com/register2.php')
|
||||
|
||||
return self.page.register(password, sex, birthday_d, birthday_m, birthday_y, zipcode, country)
|
||||
self.page.register(password, sex, birthday_d, birthday_m, birthday_y, zipcode, country)
|
||||
if godfather:
|
||||
if not self.is_on_page(AccountPage):
|
||||
self.location('http://www.adopteunmec.com/account.php')
|
||||
self.page.set_godfather(godfather)
|
||||
|
||||
@pageaccess
|
||||
def add_photo(self, name, f):
|
||||
|
|
|
|||
25
weboob/backends/aum/pages/account.py
Normal file
25
weboob/backends/aum/pages/account.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2008-2010 Christophe Benz
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from weboob.backends.aum.pages.base import PageBase
|
||||
|
||||
class AccountPage(PageBase):
|
||||
def set_godfather(self, _id):
|
||||
self.browser.select_form(name='setGodfather')
|
||||
self.browser['godfather'] = _id
|
||||
self.browser.submit()
|
||||
Loading…
Add table
Add a link
Reference in a new issue