display at least one photo url in profile even if there isn't any visible
This commit is contained in:
parent
685d389fd9
commit
f80d3839b8
1 changed files with 10 additions and 2 deletions
|
|
@ -29,7 +29,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import simplejson as json
|
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.chat import ChatException, ChatMessage
|
||||||
from weboob.capabilities.messages import CantSendMessage
|
from weboob.capabilities.messages import CantSendMessage
|
||||||
|
|
@ -341,14 +341,22 @@ class AuMBrowser(BaseBrowser):
|
||||||
d.update(pic)
|
d.update(pic)
|
||||||
profile['pictures'].append(d)
|
profile['pictures'].append(d)
|
||||||
|
|
||||||
|
base_url = 'http://s%s.adopteunmec.com/%s' % (profile['shard'], profile['path'])
|
||||||
if len(profile['pictures']) > 0:
|
if len(profile['pictures']) > 0:
|
||||||
pic_regex = re.compile('(?P<base_url>http://.+\.adopteunmec\.com/.+/)image(?P<id>.+)\.jpg')
|
pic_regex = re.compile('(?P<base_url>http://.+\.adopteunmec\.com/.+/)image(?P<id>.+)\.jpg')
|
||||||
pic_max_id = max(int(pic_regex.match(pic['url']).groupdict()['id']) for pic in profile['pictures'])
|
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):
|
for id in xrange(1, pic_max_id + 1):
|
||||||
url = u'%simage%s.jpg' % (base_url, id)
|
url = u'%simage%s.jpg' % (base_url, id)
|
||||||
if not url in [pic['url'] for pic in profile['pictures']]:
|
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})
|
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
|
return profile
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue