backported AuM last modifications
This commit is contained in:
parent
454cf3497a
commit
0ac4885ad8
8 changed files with 124 additions and 39 deletions
|
|
@ -52,12 +52,13 @@ class AdopteUnMec(Browser):
|
||||||
'http://www.adopteunmec.com/mails.php\?type=1': BasketsPage,
|
'http://www.adopteunmec.com/mails.php\?type=1': BasketsPage,
|
||||||
'http://www.adopteunmec.com/thread.php\?id=([0-9]+)': ContactThreadPage,
|
'http://www.adopteunmec.com/thread.php\?id=([0-9]+)': ContactThreadPage,
|
||||||
'http://www.adopteunmec.com/edit.php\?type=1': EditPhotoPage,
|
'http://www.adopteunmec.com/edit.php\?type=1': EditPhotoPage,
|
||||||
'http://s\d+.adopteunmec.com/upload2.php\?.*': EditPhotoCbPage,
|
'http://s\d+.adopteunmec.com/upload\d.php\?.*': EditPhotoCbPage,
|
||||||
'http://www.adopteunmec.com/edit.php\?type=2': EditAnnouncePage,
|
'http://www.adopteunmec.com/edit.php\?type=2': EditAnnouncePage,
|
||||||
'http://www.adopteunmec.com/edit.php\?type=3': EditDescriptionPage,
|
'http://www.adopteunmec.com/edit.php\?type=3': EditDescriptionPage,
|
||||||
'http://www.adopteunmec.com/edit.php\?type=4': EditSexPage,
|
'http://www.adopteunmec.com/edit.php\?type=4': EditSexPage,
|
||||||
'http://www.adopteunmec.com/edit.php\?type=5': EditPersonalityPage,
|
'http://www.adopteunmec.com/edit.php\?type=5': EditPersonalityPage,
|
||||||
'http://www.adopteunmec.com/search.php.*': SearchPage,
|
'http://www.adopteunmec.com/search.php.*': SearchPage,
|
||||||
|
'http://www.adopteunmec.com/searchRes.php.*': SearchPage,
|
||||||
'http://www.adopteunmec.com/rencontres-femmes/(.*)/([0-9]+)': ProfilePage,
|
'http://www.adopteunmec.com/rencontres-femmes/(.*)/([0-9]+)': ProfilePage,
|
||||||
'http://www.adopteunmec.com/catalogue-hommes/(.*)/([0-9]+)': ProfilePage,
|
'http://www.adopteunmec.com/catalogue-hommes/(.*)/([0-9]+)': ProfilePage,
|
||||||
'http://www.adopteunmec.com/view2.php': ProfilePage, # my own profile
|
'http://www.adopteunmec.com/view2.php': ProfilePage, # my own profile
|
||||||
|
|
@ -111,6 +112,12 @@ class AdopteUnMec(Browser):
|
||||||
self.location('/edit.php?type=2')
|
self.location('/edit.php?type=2')
|
||||||
return self.page.setAnnounce(title, description, lookingfor)
|
return self.page.setAnnounce(title, description, lookingfor)
|
||||||
|
|
||||||
|
@pageaccess
|
||||||
|
def setDescription(self, **args):
|
||||||
|
if not self.isOnPage(EditDescriptionPage):
|
||||||
|
self.location('/edit.php?type=3')
|
||||||
|
return self.page.setDescription(**args)
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def score(self):
|
def score(self):
|
||||||
if time.time() - self.__last_update > 60:
|
if time.time() - self.__last_update > 60:
|
||||||
|
|
@ -157,6 +164,11 @@ class AdopteUnMec(Browser):
|
||||||
self.location('/mails.php?type=1')
|
self.location('/mails.php?type=1')
|
||||||
return self.page.getProfilesIDsList()
|
return self.page.getProfilesIDsList()
|
||||||
|
|
||||||
|
@pageaccess
|
||||||
|
def flushVisits(self):
|
||||||
|
""" Does nothing, only flush new visits to increase my score """
|
||||||
|
self.openurl('/mails.php?type=3')
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def getContactList(self):
|
def getContactList(self):
|
||||||
if not self.isOnPage(ContactListPage):
|
if not self.isOnPage(ContactListPage):
|
||||||
|
|
@ -187,12 +199,17 @@ class AdopteUnMec(Browser):
|
||||||
# TODO check if it works (but it should)
|
# TODO check if it works (but it should)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def deblock(self, id):
|
||||||
|
result = self.openurl('http://www.adopteunmec.com/fajax_postMessage.php?action=deblock&to=%s' % id).read()
|
||||||
|
warning('Deblock: %s' % result)
|
||||||
|
return True
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def rate(self, id, what, rating):
|
def rate(self, id, what, rating):
|
||||||
print 'rate "%s"' % id, what, rating
|
print 'rate "%s"' % id, what, rating
|
||||||
result = self.openurl('http://www.adopteunmec.com/fajax_vote.php', 'member=%s&what=%s&rating=%s' % (id, what, rating)).read()
|
result = self.openurl('http://www.adopteunmec.com/fajax_vote.php', 'member=%s&what=%s&rating=%s' % (id, what, rating)).read()
|
||||||
print result
|
print result
|
||||||
return True
|
return float(result)
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def searchProfiles(self, **kwargs):
|
def searchProfiles(self, **kwargs):
|
||||||
|
|
@ -207,6 +224,23 @@ class AdopteUnMec(Browser):
|
||||||
self.location('/%s' % link)
|
self.location('/%s' % link)
|
||||||
return self.page
|
return self.page
|
||||||
|
|
||||||
|
@pageaccess
|
||||||
|
def getSlutState(self, id):
|
||||||
|
result = self.openurl('http://www.adopteunmec.com/%s' % id).read()
|
||||||
|
if result.find('<td align="right" style="font-size:12px;font-weight:bold">en ligne</td>') >= 0:
|
||||||
|
r = 'online'
|
||||||
|
elif result.find('Cet utilisateur a quitt\xe9 le site<br />') >= 0:
|
||||||
|
r = 'removed'
|
||||||
|
elif result.find('ce profil a \xe9t\xe9 bloqu\xe9 par l\'\xe9quipe de mod\xe9ration<br />') >= 0:
|
||||||
|
r = 'removed'
|
||||||
|
elif result.find('<div align=center style="color:#ff0000;font-size:16px"><br /><br />Cette personne<br>vous a bloqu\xe9</div>') >= 0:
|
||||||
|
r = 'blocked'
|
||||||
|
else:
|
||||||
|
r = 'offline'
|
||||||
|
|
||||||
|
print 'getSlutState(%s) = %s' % (id, r)
|
||||||
|
return r
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def isSlutOnline(self, id):
|
def isSlutOnline(self, id):
|
||||||
result = self.openurl('http://www.adopteunmec.com/%s' % id).read()
|
result = self.openurl('http://www.adopteunmec.com/%s' % id).read()
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,8 @@ from weboob.backend import Backend
|
||||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply
|
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply
|
||||||
|
|
||||||
class AuMBackend(Backend, ICapMessages, ICapMessagesReply):
|
class AuMBackend(Backend, ICapMessages, ICapMessagesReply):
|
||||||
pass
|
def __init__(self, weboob):
|
||||||
|
Backend.__init__(self, weboob)
|
||||||
|
|
||||||
|
def getNewMessages(self, thread=None):
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,9 @@ class MailParser(Mail):
|
||||||
if not td.hasAttribute('class') or td.getAttribute('class') != 'mini_pseudo':
|
if not td.hasAttribute('class') or td.getAttribute('class') != 'mini_pseudo':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.sender = td.childNodes[0].data
|
if td.childNodes:
|
||||||
|
self.sender = td.childNodes[0].data
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
warning('Warning: unable to find from in the mail %s' % self.getID())
|
warning('Warning: unable to find from in the mail %s' % self.getID())
|
||||||
|
|
@ -237,7 +239,7 @@ class ContactThreadPage(PageBase):
|
||||||
|
|
||||||
self.browser.submit() # submit current form
|
self.browser.submit() # submit current form
|
||||||
except FormNotFoundError:
|
except FormNotFoundError:
|
||||||
error = 'Unknown error'
|
error = 'Unknown error (%s)' % e
|
||||||
p_list = self.document.getElementsByTagName('p')
|
p_list = self.document.getElementsByTagName('p')
|
||||||
for p in p_list:
|
for p in p_list:
|
||||||
if p.hasAttribute('align') and p.getAttribute('align') == 'center':
|
if p.hasAttribute('align') and p.getAttribute('align') == 'center':
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,39 @@ class EditAnnouncePage(PageBase):
|
||||||
|
|
||||||
def setAnnounce(self, title=None, description=None, lookingfor=None):
|
def setAnnounce(self, title=None, description=None, lookingfor=None):
|
||||||
self.browser.select_form(name="form")
|
self.browser.select_form(name="form")
|
||||||
if title is not None:
|
self.browser.set_field(kwargs, 'title')
|
||||||
self.browser['title'] = title
|
self.browser.set_field(kwargs, 'description', field='about1')
|
||||||
if description is not None:
|
self.browser.set_field(kwargs, 'lookingfor', field='about2')
|
||||||
self.browser['about1'] = description
|
|
||||||
if lookingfor is not None:
|
|
||||||
self.browser['about2'] = lookingfor
|
|
||||||
|
|
||||||
self.browser.submit()
|
self.browser.submit()
|
||||||
|
|
||||||
class EditDescriptionPage(PageBase):
|
class EditDescriptionPage(PageBase):
|
||||||
pass
|
SHAPES = ['--', 'svelte', 'sportive', u'équilibrée', 'pulpeuse', u'généreuse', 'normale']
|
||||||
|
HAIR_COLORS = ['--', 'blancs', 'gris', 'noirs', 'bruns', 'chatains', 'roux', 'blonds', 'platines', u'colorés']
|
||||||
|
HAIR_SIZES = ['--', u'rasés', 'courts', 'mi-longs', 'longs']
|
||||||
|
EYES = ['--', 'noirs', 'marrons', 'noisettes', 'bleus', 'verts', 'gris']
|
||||||
|
ORIGINS = ['--', u'européennes', 'afro', 'maghrebines', 'asiatiques', u'métisses', 'eurasiennes', 'latines']
|
||||||
|
STYLES = ['--', 'fashion', 'chic', 'sport', u'décontracté', 'rock', u'bohème', 'masculin', 'dark', 'excentrique', 'electro', 'skate']
|
||||||
|
FOODS = ['--', 'mange de tout', 'piscovore', u'végétarien', u'végétalien', 'bio']
|
||||||
|
DRINKS = ['--', 'jamais', 'de temps en temps', 'souvent', 'pilier de bar']
|
||||||
|
SMOKES = ['--', u'ne tolère pas la fumée', u'tolère la fumée', 'fume de temps en temps', 'fume souvent']
|
||||||
|
|
||||||
|
def setDescription(self, **kwargs):
|
||||||
|
self.browser.select_form(name='form')
|
||||||
|
|
||||||
|
self.browser.set_field(kwargs, 'height', field='size', is_list=True)
|
||||||
|
self.browser.set_field(kwargs, 'weight', is_list=True)
|
||||||
|
self.browser.set_field(kwargs, 'shape', is_list=self.SHAPES)
|
||||||
|
self.browser.set_field(kwargs, 'hair_color', is_list=self.HAIR_COLORS)
|
||||||
|
self.browser.set_field(kwargs, 'hair_size', is_list=self.HAIR_SIZES)
|
||||||
|
self.browser.set_field(kwargs, 'eyes', is_list=self.EYES)
|
||||||
|
self.browser.set_field(kwargs, 'origins', is_list=self.ORIGINS)
|
||||||
|
self.browser.set_field(kwargs, 'style', is_list=self.STYLES)
|
||||||
|
self.browser.set_field(kwargs, 'food', is_list=self.FOODS)
|
||||||
|
self.browser.set_field(kwargs, 'drink', is_list=self.DRINKS)
|
||||||
|
self.browser.set_field(kwargs, 'smoke', is_list=self.SMOKES)
|
||||||
|
|
||||||
|
self.browser.submit()
|
||||||
|
|
||||||
class EditSexPage(PageBase):
|
class EditSexPage(PageBase):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ class RegisterPage(PageBase):
|
||||||
- godfather
|
- godfather
|
||||||
"""
|
"""
|
||||||
self.browser.select_form(name="form2")
|
self.browser.select_form(name="form2")
|
||||||
self.browser.controls.pop()
|
self.browser.controls.pop() # pop the 'sex' control which is twice on page
|
||||||
|
self.browser.set_all_readonly(False)
|
||||||
|
|
||||||
if isinstance(nickname, unicode):
|
if isinstance(nickname, unicode):
|
||||||
nickname = nickname.encode('iso-8859-15', 'ignore')
|
nickname = nickname.encode('iso-8859-15', 'ignore')
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,25 @@ class FieldWideList(FieldBase):
|
||||||
d[self.key] += [value]
|
d[self.key] += [value]
|
||||||
|
|
||||||
class FieldOld(FieldBase):
|
class FieldOld(FieldBase):
|
||||||
regexp = re.compile('([0-9]+) ans')
|
regexp = re.compile(u'([0-9]+) ans( \(Née le ([0-9]+) ([^ ]+) ([0-9]+)\))?')
|
||||||
|
month2i = ['', 'janvier', u'février', 'mars', 'avril', 'mai', 'juin', 'juillet', u'août', 'septembre', 'octobre', 'novembre', u'décembre']
|
||||||
|
|
||||||
def putValue(self, d, value):
|
def putValue(self, d, value):
|
||||||
m = self.regexp.match(value)
|
m = self.regexp.match(value)
|
||||||
if m:
|
warning(value)
|
||||||
d[self.key] = int(m.group(1))
|
if not m:
|
||||||
|
return
|
||||||
|
|
||||||
|
d[self.key] = int(m.group(1))
|
||||||
|
if not m.group(2):
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
d['birthday'] = (int(m.group(3)),
|
||||||
|
self.month2i.index(m.group(4)),
|
||||||
|
int(m.group(5)))
|
||||||
|
except ValueError, e:
|
||||||
|
print str(e)
|
||||||
|
|
||||||
class FieldLocation(FieldBase):
|
class FieldLocation(FieldBase):
|
||||||
location = re.compile('(.*) \(([0-9]{5})\), (.*)')
|
location = re.compile('(.*) \(([0-9]{5})\), (.*)')
|
||||||
|
|
@ -114,6 +128,7 @@ class FieldParticularSignes(FieldBase):
|
||||||
class ProfilePage(PageBase):
|
class ProfilePage(PageBase):
|
||||||
|
|
||||||
empty_table = {'details': {'old': 0,
|
empty_table = {'details': {'old': 0,
|
||||||
|
'birthday': (0,0,0),
|
||||||
'zipcode': 0,
|
'zipcode': 0,
|
||||||
'location': '',
|
'location': '',
|
||||||
'country': '',
|
'country': '',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Copyright(C) 2008 Romain Bignon
|
Copyright(C) 2008-2010 Romain Bignon
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -22,33 +22,18 @@ import ClientForm
|
||||||
from weboob.backends.aum.pages.profileslist_base import ProfilesListBase
|
from weboob.backends.aum.pages.profileslist_base import ProfilesListBase
|
||||||
|
|
||||||
class SearchPage(ProfilesListBase):
|
class SearchPage(ProfilesListBase):
|
||||||
|
|
||||||
SHOW_WITHOUT_PHOTO = False
|
SHOW_WITHOUT_PHOTO = False
|
||||||
|
|
||||||
def set_field(self, args, label, field=None, value=None, is_list=False):
|
|
||||||
try:
|
|
||||||
if not field:
|
|
||||||
field = label
|
|
||||||
if args.get(label, None) is not None:
|
|
||||||
if not value:
|
|
||||||
if is_list:
|
|
||||||
value = [str(args[label])]
|
|
||||||
else:
|
|
||||||
value = str(args[label])
|
|
||||||
self.browser[field] = value
|
|
||||||
except ClientForm.ControlNotFoundError:
|
|
||||||
return
|
|
||||||
|
|
||||||
def search(self, **kwargs):
|
def search(self, **kwargs):
|
||||||
|
|
||||||
self.browser.select_form(name="form")
|
self.browser.select_form(name="form")
|
||||||
self.browser.set_all_readonly(False)
|
self.browser.set_all_readonly(False)
|
||||||
|
|
||||||
self.set_field(kwargs, 'ageMin', is_list=True)
|
self.browser.set_field(kwargs, 'ageMin', is_list=True)
|
||||||
self.set_field(kwargs, 'ageMax', is_list=True)
|
self.browser.set_field(kwargs, 'ageMax', is_list=True)
|
||||||
self.set_field(kwargs, 'country', is_list=True)
|
self.browser.set_field(kwargs, 'country', is_list=True)
|
||||||
self.set_field(kwargs, 'dist', is_list=True)
|
self.browser.set_field(kwargs, 'dist', is_list=True)
|
||||||
self.set_field(kwargs, 'nickname', field='pseudo')
|
self.browser.set_field(kwargs, 'nickname', field='pseudo')
|
||||||
self.set_field(kwargs, 'save', value='true')
|
self.browser.set_field(kwargs, 'save', value='true')
|
||||||
|
self.browser['originsV[]'] = ['1'] # excludes niggers (it doesn't work :( )
|
||||||
|
|
||||||
self.browser.submit()
|
self.browser.submit()
|
||||||
|
|
|
||||||
|
|
@ -219,3 +219,25 @@ class Browser(mechanize.Browser):
|
||||||
if self.__cookie:
|
if self.__cookie:
|
||||||
self.__cookie.save()
|
self.__cookie.save()
|
||||||
|
|
||||||
|
def set_field(self, args, label, field=None, value=None, is_list=False):
|
||||||
|
try:
|
||||||
|
if not field:
|
||||||
|
field = label
|
||||||
|
if args.get(label, None) is not None:
|
||||||
|
if not value:
|
||||||
|
if is_list:
|
||||||
|
if isinstance(is_list, (list, tuple)):
|
||||||
|
try:
|
||||||
|
value = [str(is_list.index(args[label]))]
|
||||||
|
except ValueError, e:
|
||||||
|
if args[label]:
|
||||||
|
print '[%s] %s: %s' % (label, args[label], e)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
value = [str(args[label])]
|
||||||
|
else:
|
||||||
|
value = str(args[label])
|
||||||
|
self[field] = value
|
||||||
|
except ClientForm.ControlNotFoundError:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue