[tumblr] prevent premature exit to get all images (fixes #48)

pull/54/head
Mike Fährmann 7 years ago
parent 305da540c3
commit d6bed9f36f
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -30,7 +30,7 @@ class TumblrUserExtractor(Extractor):
Extractor.__init__(self) Extractor.__init__(self)
self.user = match.group(1) self.user = match.group(1)
self.api_url = "https://{}.tumblr.com/api/read/json".format(self.user) self.api_url = "https://{}.tumblr.com/api/read/json".format(self.user)
self.api_params = {"start": 0, "type": "photo"} self.api_params = {"start": 0, "type": "photo", "num": 20}
def items(self): def items(self):
images = self.get_image_data() images = self.get_image_data()
@ -66,8 +66,8 @@ class TumblrUserExtractor(Extractor):
yield data["tumblelog"] yield data["tumblelog"]
for post in data["posts"]: for post in data["posts"]:
yield from self.get_images_from_post(post) yield from self.get_images_from_post(post)
if len(data["posts"]) < 20: if not data["posts"] or "id" in params:
break return
params["start"] += 20 params["start"] += 20
@staticmethod @staticmethod

Loading…
Cancel
Save