remove useless features of module that don't work anymore
This commit is contained in:
parent
be7d49312d
commit
f1b6d27823
5 changed files with 3 additions and 481 deletions
|
|
@ -1,214 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010-2011 Romain Bignon
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
raise ImportError('Please install python-imaging')
|
||||
|
||||
|
||||
class CaptchaError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Tile(object):
|
||||
hash = {
|
||||
'bc8d52d96058478a6def26226145d53b': 'A',
|
||||
'c62ecdfddb72b2feaed96cd9fe7c2802': 'A',
|
||||
'8b61cda8a3240d8fa5f2610424271300': 'AD',
|
||||
'f5dc63d37c7ea3375d86180f0ae62d05': 'AE',
|
||||
'fd562be230da7f767f4454148632201d': 'AF',
|
||||
'1860de576d8b0d1d87edc9dcb0b2a64c': 'AG',
|
||||
'53afa108d36186e6bd23631711ec3d8c': 'AJ',
|
||||
'6f2f9a1082a9230272c45117320f159d': 'AL',
|
||||
'e14249a774d24bacc6e2bcadd7f3df65': 'AM',
|
||||
'389330dbf3d85dea2dc40c6f9cf77d52': 'AN',
|
||||
'17526a3c2261b55f9cd237c4aa195099': 'AQ',
|
||||
'7e4820a9cc6c83a9fa60ff73ceb52157': 'AW',
|
||||
'90690d1209753a2bcfeafa890082a585': 'B',
|
||||
'2cf22e9ceace03a5f8ed3999e92d877e': 'C',
|
||||
'a1d0bf1a29600a82a6aa2b8b21651b0f': 'D',
|
||||
'9bb6909d647a0be3b2e7352d37374228': 'E',
|
||||
'38120c8346f16cd07a9194283787ee5e': 'F',
|
||||
'd41ff948fbc50a628c858b8e3e9e931c': 'G',
|
||||
'4cc9322d3361eb3f9fea7fc83579e40f': 'H',
|
||||
'837cd0f04e2d47ca6975745bdd0da640': 'I',
|
||||
'da0204fa51b38414051376cc1c27ba72': 'J',
|
||||
'199b1a9f9e1df1c2eddadcc4582957d7': 'JW',
|
||||
'5e8d3d5bd5f683d84b089f2cecc1e196': 'JX',
|
||||
'bc1fcf3546057d40d2db5454caacb3a5': 'JZ',
|
||||
'c2f5866ba3bf799ece8b202492d199bf': 'K',
|
||||
'7abe4091e11921afe6dac16509999010': 'KT',
|
||||
'281ef08e623184e5621a73b9ccec7c9a': 'KX',
|
||||
'b28e3fc06411de2ac7f53569bc3b42db': 'L',
|
||||
'd58a6c26649926f1145fb4b7b42d0554': 'LT',
|
||||
'4add630c6d124899fef814211975e344': 'M',
|
||||
'9740cefe1629d6bc149a72d5f2a4586d': 'N',
|
||||
'396f816f7e78e5c98de6404f8c4bd2ee': 'O',
|
||||
'31ae7c9536b6c6a96e30a77b70e4b2fd': 'P',
|
||||
'98ad9b1c32c05e6efc06637a166e4c42': 'PA',
|
||||
'a05cce33683025fb2c6708ee06f6028e': 'Q',
|
||||
'2852f51e8939bf9664fe064f7dacf310': 'R',
|
||||
'3798513fe87e786faa67552a140fd86f': 'S',
|
||||
'350b13811e34eeb63e3d7fb4b5eade5b': 'T',
|
||||
'a01b186cbc767e17d948ed04eff114a1': 'U',
|
||||
'8405f4d80ce80c4e6e9680fcfac4fe40': 'V',
|
||||
'17ed80e9cb9a585098ae6a55d8d1f5c0': 'W',
|
||||
'ae54ca77be5561330781a08dfbaff7a7': 'W',
|
||||
'bbded6a2ba5f521bba276bb843bf4c98': 'WXT',
|
||||
'ea662dd25fc528b84b832ce71ae3de61': 'WZ',
|
||||
'4eb23916138e7c01714431dbecfe8b96': 'X',
|
||||
'c02093d35d852339ff34f2b26873bf5a': 'XW',
|
||||
'65744e0c6ce0c56d04873dfd732533a7': 'Y',
|
||||
'315fb7dba7032004bd362cf0bb076733': 'YA',
|
||||
'ce12a68a4f15657bc5297a6cf698bc0a': 'YAQ',
|
||||
'275478ea2280351f7433a0606f962175': 'Z',
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
self.map = []
|
||||
|
||||
def append(self, pxls):
|
||||
self.map.append(pxls)
|
||||
|
||||
def display(self):
|
||||
print('-' * (len(self.map) * 2 + 2))
|
||||
for y in xrange(len(self.map[0])):
|
||||
sys.stdout.write('|')
|
||||
for x in xrange(len(self.map)):
|
||||
sys.stdout.write('%s' % ('XX' if self.map[x][y] else ' '))
|
||||
print('|')
|
||||
print('-' * (len(self.map) * 2 + 2))
|
||||
|
||||
def checksum(self):
|
||||
s = ''
|
||||
for pxls in self.map:
|
||||
for pxl in pxls:
|
||||
s += '%d' % (1 if pxl else 0)
|
||||
return hashlib.md5(s).hexdigest()
|
||||
|
||||
@property
|
||||
def letter(self):
|
||||
checksum = self.checksum()
|
||||
try:
|
||||
return self.hash[checksum]
|
||||
except KeyError:
|
||||
print('Unable te resolve:')
|
||||
self.display()
|
||||
print('hash: %s' % checksum)
|
||||
raise CaptchaError()
|
||||
|
||||
|
||||
class Captcha(object):
|
||||
def __init__(self, f):
|
||||
self.img = Image.open(f)
|
||||
self.w, self.h = self.img.size
|
||||
self.map = self.img.load()
|
||||
|
||||
self.tiles = []
|
||||
|
||||
tile = None
|
||||
for x in xrange(self.w):
|
||||
blank = True
|
||||
pxls = []
|
||||
for y in xrange(self.h):
|
||||
pxls.append(self[x,y])
|
||||
if self[x,y] != 0:
|
||||
blank = False
|
||||
|
||||
if tile:
|
||||
if blank:
|
||||
tile = None
|
||||
else:
|
||||
tile.append(pxls)
|
||||
elif not blank:
|
||||
tile = Tile()
|
||||
tile.append(pxls)
|
||||
self.tiles.append(tile)
|
||||
|
||||
def __getitem__(self, (x, y)):
|
||||
return self.map[x % self.w, y % self.h]
|
||||
|
||||
def __iter__(self):
|
||||
for tile in self.tiles:
|
||||
yield tile
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
s = ''
|
||||
for tile in self.tiles:
|
||||
s += tile.letter
|
||||
return s
|
||||
|
||||
|
||||
class Decoder(object):
|
||||
def __init__(self):
|
||||
self.hash = {}
|
||||
|
||||
def process(self):
|
||||
from aum.browser import AuMBrowser
|
||||
browser = AuMBrowser('')
|
||||
browser.openurl('/register2.php')
|
||||
c = Captcha(browser.openurl('/captcha.php'))
|
||||
|
||||
for tile in c:
|
||||
checksum = tile.checksum()
|
||||
|
||||
if checksum in self.hash:
|
||||
print('Skipping %s' % self.hash[checksum])
|
||||
continue
|
||||
|
||||
tile.display()
|
||||
print('Checksum: %s' % checksum)
|
||||
ntry = 2
|
||||
while ntry:
|
||||
sys.stdout.write('Enter the letter: ')
|
||||
l = sys.stdin.readline().strip()
|
||||
|
||||
ntry -= 1
|
||||
if len(l) != 1:
|
||||
print('Error: please enter only one letter')
|
||||
elif l in self.hash.itervalues():
|
||||
print('Warning! This letter has already been catched!')
|
||||
else:
|
||||
ntry = 0
|
||||
|
||||
self.hash[checksum] = l
|
||||
|
||||
def main(self):
|
||||
try:
|
||||
while True:
|
||||
self.process()
|
||||
except KeyboardInterrupt:
|
||||
print('')
|
||||
print('hash = {')
|
||||
l = sorted(self.hash.iteritems(), key=lambda (k,v): (v,k))
|
||||
for hash, value in l:
|
||||
print(' \'%s\': %s' % (hash, value))
|
||||
|
||||
print('}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
d = Decoder()
|
||||
d.main()
|
||||
|
|
@ -18,10 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
import email
|
||||
import time
|
||||
import re
|
||||
import datetime
|
||||
from html2text import unescape
|
||||
from dateutil import tz
|
||||
|
|
@ -35,13 +32,11 @@ from weboob.capabilities.contact import CapContact, ContactPhoto, Query, QueryEr
|
|||
from weboob.capabilities.account import CapAccount, StatusField
|
||||
from weboob.tools.backend import Module, BackendConfig
|
||||
from weboob.tools.browser import BrowserUnavailable, BrowserHTTPNotFound
|
||||
from weboob.tools.value import Value, ValuesDict, ValueBool, ValueBackendPassword
|
||||
from weboob.tools.log import getLogger
|
||||
from weboob.tools.value import Value, ValueBool, ValueBackendPassword
|
||||
from weboob.tools.date import local2utc
|
||||
from weboob.tools.misc import to_unicode
|
||||
|
||||
from .contact import Contact
|
||||
from .captcha import CaptchaError
|
||||
from .antispam import AntiSpam
|
||||
from .browser import AuMBrowser
|
||||
from .optim.profiles_walker import ProfilesWalker
|
||||
|
|
@ -471,81 +466,6 @@ class AuMModule(Module, CapMessages, CapMessagesPost, CapDating, CapChat, CapCon
|
|||
#def start_chat_polling(self):
|
||||
#self._profile_walker = ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)
|
||||
|
||||
# ---- CapAccount methods ---------------------
|
||||
|
||||
ACCOUNT_REGISTER_PROPERTIES = ValuesDict(
|
||||
Value('username', label='Email address', regexp='^[^ ]+@[^ ]+\.[^ ]+$'),
|
||||
Value('password', label='Password', regexp='^[^ ]+$', masked=True),
|
||||
Value('sex', label='Sex', choices={'m': 'Male', 'f': 'Female'}),
|
||||
Value('birthday', label='Birthday (dd/mm/yyyy)', regexp='^\d+/\d+/\d+$'),
|
||||
Value('zipcode', label='Zipcode'),
|
||||
Value('country', label='Country', choices={'fr': 'France', 'be': 'Belgique', 'ch': 'Suisse', 'ca': 'Canada'}, default='fr'),
|
||||
Value('godfather',label='Godfather', regexp='^\d*$', default=''),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def register_account(klass, account):
|
||||
"""
|
||||
Register an account on website
|
||||
|
||||
This is a static method, it would be called even if the backend is
|
||||
instancied.
|
||||
|
||||
@param account an Account object which describe the account to create
|
||||
"""
|
||||
browser = None
|
||||
bday, bmonth, byear = account.properties['birthday'].get().split('/', 2)
|
||||
while not browser:
|
||||
try:
|
||||
browser = klass.BROWSER(account.properties['username'].get())
|
||||
browser.register(password= account.properties['password'].get(),
|
||||
sex= (0 if account.properties['sex'].get() == 'm' else 1),
|
||||
birthday_d= int(bday),
|
||||
birthday_m= int(bmonth),
|
||||
birthday_y= int(byear),
|
||||
zipcode= account.properties['zipcode'].get(),
|
||||
country= account.properties['country'].get(),
|
||||
godfather= account.properties['godfather'].get())
|
||||
except CaptchaError:
|
||||
getLogger('aum').info('Unable to resolve captcha. Retrying...')
|
||||
browser = None
|
||||
|
||||
REGISTER_REGEXP = re.compile('.*http://www.adopteunmec.com/register4.php\?([^\' ]*)\'')
|
||||
|
||||
def confirm_account(self, mail):
|
||||
msg = email.message_from_string(mail)
|
||||
|
||||
content = u''
|
||||
for part in msg.walk():
|
||||
s = part.get_payload(decode=True)
|
||||
content += unicode(s, 'iso-8859-15')
|
||||
|
||||
url = None
|
||||
for s in content.split():
|
||||
m = self.REGISTER_REGEXP.match(s)
|
||||
if m:
|
||||
url = '/register4.php?' + m.group(1)
|
||||
break
|
||||
|
||||
if url:
|
||||
browser = self.create_browser('')
|
||||
browser.openurl(url)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def get_account(self):
|
||||
"""
|
||||
Get the current account.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def update_account(self, account):
|
||||
"""
|
||||
Update the current account.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_account_status(self):
|
||||
with self.browser:
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,180 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010-2011 Romain Bignon
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import random
|
||||
|
||||
from weboob.tools.browser import BrowserUnavailable, BrowserIncorrectPassword
|
||||
from weboob.capabilities.dating import Optimization
|
||||
from weboob.capabilities.account import AccountRegisterError
|
||||
from weboob.tools.log import getLogger
|
||||
from weboob.tools.value import Value, ValuesDict, ValueInt
|
||||
|
||||
from aum.captcha import CaptchaError
|
||||
from aum.exceptions import AdopteWait, AdopteBanned
|
||||
from aum.browser import AuMBrowser
|
||||
|
||||
|
||||
class PriorityConnection(Optimization):
|
||||
CONFIG = ValuesDict(ValueInt('minimal', label='Minimal of godchilds', default=5),
|
||||
Value('domain', label='Domain to use for fake accounts emails', default='aum.example.com'),
|
||||
ValueInt('interval', label='Interval of checks (seconds)', default=3600)
|
||||
)
|
||||
|
||||
def __init__(self, sched, storage, browser):
|
||||
self.sched = sched
|
||||
self.storage = storage
|
||||
self.browser = browser
|
||||
self.logger = getLogger('priorityconn', browser.logger)
|
||||
|
||||
self.config = storage.get('priority_connection', 'config', default=None)
|
||||
if self.config == {}:
|
||||
self.config = None
|
||||
|
||||
self.check_cron = None
|
||||
self.activity_cron = None
|
||||
|
||||
def start(self):
|
||||
if self.config is None:
|
||||
return False
|
||||
|
||||
self.check_cron = self.sched.repeat(int(self.config['interval']), self.check_godchilds)
|
||||
self.activity_cron = self.sched.repeat(600, self.activity_fakes)
|
||||
return True
|
||||
|
||||
def stop(self):
|
||||
self.sched.cancel(self.check_cron)
|
||||
self.check_cron = None
|
||||
self.sched.cancel(self.activity_cron)
|
||||
self.activity_cron = None
|
||||
return True
|
||||
|
||||
def is_running(self):
|
||||
return self.check_cron is not None
|
||||
|
||||
def set_config(self, params):
|
||||
self.config = params
|
||||
self.storage.set('priority_connection', 'config', self.config)
|
||||
self.storage.save()
|
||||
|
||||
def get_config(self):
|
||||
return self.config
|
||||
|
||||
def generate_name(self):
|
||||
login = u''
|
||||
for x in xrange(8):
|
||||
if x % 2:
|
||||
login += random.choice(u'aeiou')
|
||||
else:
|
||||
login += random.choice(u'bcdfghjklmnprstv')
|
||||
|
||||
fakes = self.storage.get('priority_connection', 'fakes')
|
||||
while ('%s@%s' % (login, self.config['domain'])) in fakes.iterkeys():
|
||||
login += '_'
|
||||
return login
|
||||
|
||||
def generate_password(self):
|
||||
return '%08x' % random.randint(1, int('ffffffff', 16))
|
||||
|
||||
def check_godchilds(self):
|
||||
with self.browser:
|
||||
try:
|
||||
my_id = self.browser.get_my_id()
|
||||
nb_godchilds = self.browser.nb_godchilds()
|
||||
except AdopteWait:
|
||||
nb_godchilds = 0
|
||||
except BrowserUnavailable:
|
||||
# We'll check later
|
||||
return
|
||||
|
||||
missing_godchilds = int(self.config['minimal']) - nb_godchilds
|
||||
|
||||
self.logger.info('Missing godchilds: %s' % missing_godchilds)
|
||||
|
||||
if missing_godchilds <= 0:
|
||||
return
|
||||
|
||||
for i in xrange(missing_godchilds):
|
||||
registered = False
|
||||
while not registered:
|
||||
name = self.generate_name()
|
||||
password = self.generate_password()
|
||||
|
||||
browser = AuMBrowser('%s@%s' % (name, self.config['domain']), proxy=self.browser.proxy)
|
||||
try:
|
||||
browser.register(password= password,
|
||||
sex= 1, # slut
|
||||
birthday_d= random.randint(1, 28),
|
||||
birthday_m= random.randint(1, 12),
|
||||
birthday_y= random.randint(1975, 1990),
|
||||
zipcode= 75001,
|
||||
country= 'fr',
|
||||
godfather= my_id)
|
||||
except AccountRegisterError as e:
|
||||
self.logger.warning('Unable to register account: %s' % e)
|
||||
except CaptchaError:
|
||||
self.logger.warning('Unable to solve captcha... Retrying')
|
||||
else:
|
||||
registered = True
|
||||
|
||||
# set nickname
|
||||
browser.set_nickname(name.strip('_').capitalize())
|
||||
# rate my own profile with good score
|
||||
for i in xrange(4):
|
||||
browser.rate(my_id, i, 5.0)
|
||||
|
||||
# save fake in storage
|
||||
fake = {'username': browser.username,
|
||||
'password': password}
|
||||
self.storage.set('priority_connection', 'fakes', name, fake)
|
||||
self.storage.save()
|
||||
self.logger.info('Fake account "%s" created (godfather=%s)' % (name, my_id))
|
||||
|
||||
def activity_fakes(self):
|
||||
try:
|
||||
fakes = self.storage.get('priority_connection', 'fakes', default={})
|
||||
if len(fakes) == 0:
|
||||
return
|
||||
while True:
|
||||
name = random.choice(fakes.keys())
|
||||
fake = fakes[name]
|
||||
try:
|
||||
browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy)
|
||||
except (AdopteBanned,BrowserIncorrectPassword) as e:
|
||||
self.logger.warning('Fake %s can\'t login: %s' % (name, e))
|
||||
continue
|
||||
|
||||
profiles = browser.search_profiles(country="fr",
|
||||
dist='10',
|
||||
save=True)
|
||||
|
||||
if not profiles:
|
||||
continue
|
||||
|
||||
id = profiles.pop()
|
||||
profile = browser.get_profile(id)
|
||||
# bad rate
|
||||
for i in xrange(4):
|
||||
browser.rate(profile.get_id(), i, 0.6)
|
||||
# deblock
|
||||
browser.deblock(profile.get_id())
|
||||
return
|
||||
except BrowserUnavailable:
|
||||
# don't care
|
||||
pass
|
||||
|
|
@ -17,8 +17,6 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from random import randint
|
||||
|
||||
from weboob.tools.browser import BrowserUnavailable
|
||||
|
|
@ -94,7 +92,7 @@ class ProfilesWalker(Optimization):
|
|||
self.profiles_queue.add(id)
|
||||
return
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.logger.exception(e)
|
||||
finally:
|
||||
if self.view_cron is not None:
|
||||
self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from weboob.tools.browser import BrowserUnavailable
|
||||
from weboob.capabilities.dating import Optimization
|
||||
|
|
@ -45,6 +44,5 @@ class Visibility(Optimization):
|
|||
try:
|
||||
with self.browser:
|
||||
self.browser.login()
|
||||
except BrowserUnavailable as e:
|
||||
print(str(e))
|
||||
except BrowserUnavailable:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue