[tumblr] add option to filter reblogged posts (#61)

Reblogs are ignored by default, but can be included by setting
'extractor.tumblr.reblogs' to 'true'.
pull/73/head
Mike Fährmann 7 years ago
parent a794fffc6d
commit d235f68f59
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -644,6 +644,15 @@ Description Search posts for inline images.
=========== =====
extractor.tumblr.reblogs
------------------------
=========== =====
Type ``bool``
Default ``false``
Description Extract images from reblogged posts.
=========== =====
extractor.tumblr.posts
----------------------
=========== =====

@ -111,6 +111,7 @@
{
"posts": "photo",
"inline": false,
"reblogs": false,
"external": false
},
"recursive":

@ -49,6 +49,7 @@ class TumblrExtractor(Extractor):
self.types = self._setup_posttypes()
self.inline = self.config("inline", False)
self.reblogs = self.config("reblogs", False)
self.external = self.config("external", False)
if len(self.types) == 1:
@ -65,6 +66,11 @@ class TumblrExtractor(Extractor):
if post["type"] not in self.types:
continue
reblog = "reblogged_from_id" in post
if reblog and not self.reblogs:
continue
post["reblogged"] = reblog
post["blog"] = blog
post["offset"] = 0
@ -145,7 +151,8 @@ class TumblrUserExtractor(TumblrExtractor):
r"\d+\.media\.tumblr\.com/tumblr_[^/_]+_1280\.jpg|"
r"w+\.tumblr\.com/audio_file/demo/\d+/tumblr_\w+)"),
"count": 3,
"options": (("posts", "all"), ("external", True), ("inline", True))
"options": (("posts", "all"), ("external", True),
("inline", True), ("reblogs", True))
}),
]
@ -165,6 +172,7 @@ class TumblrPostExtractor(TumblrExtractor):
def __init__(self, match):
TumblrExtractor.__init__(self, match)
self.post_id = match.group(2)
self.reblogs = True
def posts(self):
return self.api.posts(self.user, {"id": self.post_id})
@ -197,7 +205,7 @@ class TumblrAPI():
def __init__(self, extractor):
self.api_key = extractor.config("api-key", TumblrAPI.API_KEY)
self.params = {"offset": 0, "limit": 50}
self.params = {"offset": 0, "limit": 50, "reblog_info": "true"}
self.extractor = extractor
@memcache(keyarg=1)

Loading…
Cancel
Save