Commit 3c031647 authored by Vincent A's avatar Vincent A

[tumblr] fetch gallery avatar

parent 65b21610
......@@ -40,9 +40,12 @@ class TumblrBrowser(APIBrowser):
r = re.sub(r'^var tumblr_api_read = (.*);$', r'\1', r)
return json.loads(r)
def get_title(self):
def get_title_icon(self):
r = self.request('/api/read/json?type=photo&num=1&start=0&filter=text')
return r['tumblelog']['title']
icon = None
if r['posts']:
icon = r['posts'][0]['tumblelog']['avatar_url_512']
return (r['tumblelog']['title'], icon)
def iter_images(self, gallery):
index = 0
......@@ -21,7 +21,7 @@ from __future__ import unicode_literals
from weboob.browser.exceptions import ClientError, HTTPNotFound
from import CapGallery, BaseGallery, BaseImage
from import CapGallery, BaseGallery, BaseImage, Thumbnail
from import Module, BackendConfig
from import urlparse
from import Value
......@@ -50,7 +50,10 @@ class TumblrModule(Module, CapGallery):
return self.config['url'].get()
def get_gallery(self, _id):
return BaseGallery(_id, title=self.browser.get_title(), url=self.url())
title, icon = self.browser.get_title_icon()
if icon:
icon = Thumbnail(icon)
return BaseGallery(_id, title=title, url=self.url(), thumbnail=icon)
def search_galleries(self, pattern, sortby=CapGallery.SEARCH_RELEVANCE):
pattern = pattern.lower()
......@@ -73,4 +76,5 @@ class TumblrModule(Module, CapGallery):
BaseImage: fill_img,
BaseGallery: fill_img,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment