From f80d3839b87ba1837e229f867a6ffb949ec3e54c Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Mon, 28 Nov 2011 11:10:56 +0100 Subject: [PATCH] display at least one photo url in profile even if there isn't any visible --- weboob/backends/aum/browser.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/weboob/backends/aum/browser.py b/weboob/backends/aum/browser.py index 4084a856..f58dc110 100644 --- a/weboob/backends/aum/browser.py +++ b/weboob/backends/aum/browser.py @@ -29,7 +29,7 @@ try: except ImportError: import simplejson as json -from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserUnavailable +from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserUnavailable, BrowserHTTPNotFound from weboob.capabilities.chat import ChatException, ChatMessage from weboob.capabilities.messages import CantSendMessage @@ -341,14 +341,22 @@ class AuMBrowser(BaseBrowser): d.update(pic) profile['pictures'].append(d) + base_url = 'http://s%s.adopteunmec.com/%s' % (profile['shard'], profile['path']) if len(profile['pictures']) > 0: pic_regex = re.compile('(?Phttp://.+\.adopteunmec\.com/.+/)image(?P.+)\.jpg') pic_max_id = max(int(pic_regex.match(pic['url']).groupdict()['id']) for pic in profile['pictures']) - base_url = pic_regex.match(profile['pictures'][0]['url']).groupdict()['base_url'] for id in xrange(1, pic_max_id + 1): url = u'%simage%s.jpg' % (base_url, id) if not url in [pic['url'] for pic in profile['pictures']]: profile['pictures'].append({'url': url, u'hidden': True, 'id': u'0', 'rating': 0.0}) + else: + url = '%simage1.jpg' % base_url + try: + self.openurl(url) + except BrowserHTTPNotFound, e: + pass + else: + profile['pictures'].append({'url': url, u'hidden': True, 'id': u'0', 'rating': 0.0}) return profile