[patreon] include image info in API results (#383)
This commit is contained in:
@@ -35,28 +35,27 @@ class PatreonExtractor(Extractor):
|
|||||||
for post in self.posts():
|
for post in self.posts():
|
||||||
yield Message.Directory, post
|
yield Message.Directory, post
|
||||||
|
|
||||||
|
ids = set()
|
||||||
post["num"] = 0
|
post["num"] = 0
|
||||||
content = post.get("content")
|
content = post.get("content")
|
||||||
postfile = post.get("post_file")
|
postfile = post.get("post_file")
|
||||||
|
|
||||||
if postfile:
|
|
||||||
post["num"] += 1
|
|
||||||
post["type"] = "postfile"
|
|
||||||
text.nameext_from_url(postfile["name"], post)
|
|
||||||
yield Message.Url, postfile["url"], post
|
|
||||||
postfile_id = "/" + postfile["url"].split("/")[-2] + "/"
|
|
||||||
|
|
||||||
for image in post["images"]:
|
for image in post["images"]:
|
||||||
url = image.get("download_url")
|
url = image.get("download_url")
|
||||||
if not url:
|
if not url:
|
||||||
continue
|
continue
|
||||||
if postfile and postfile_id in url:
|
ids.add(url.split("/")[-2])
|
||||||
postfile = None
|
name = image.get("file_name") or self._filename(url) or url
|
||||||
continue
|
|
||||||
post["num"] += 1
|
post["num"] += 1
|
||||||
post["type"] = "image"
|
post["type"] = "image"
|
||||||
text.nameext_from_url(self._filename(url) or url, post)
|
yield Message.Url, url, text.nameext_from_url(name, post)
|
||||||
yield Message.Url, url, post
|
|
||||||
|
if postfile and postfile["url"].split("/")[-2] not in ids:
|
||||||
|
post["num"] += 1
|
||||||
|
post["type"] = "postfile"
|
||||||
|
text.nameext_from_url(postfile["name"], post)
|
||||||
|
yield Message.Url, postfile["url"], post
|
||||||
|
|
||||||
for attachment in post["attachments"]:
|
for attachment in post["attachments"]:
|
||||||
post["num"] += 1
|
post["num"] += 1
|
||||||
@@ -140,9 +139,10 @@ class PatreonExtractor(Extractor):
|
|||||||
return (
|
return (
|
||||||
"https://www.patreon.com/api/" + endpoint +
|
"https://www.patreon.com/api/" + endpoint +
|
||||||
|
|
||||||
"?include=user,attachments,user_defined_tags,campaign,poll.choices"
|
"?include=user,images,attachments,user_defined_tags,campaign,poll."
|
||||||
",poll.current_user_responses.user,poll.current_user_responses.cho"
|
"choices,poll.current_user_responses.user,poll.current_user_respon"
|
||||||
"ice,poll.current_user_responses.poll,access_rules.tier.null"
|
"ses.choice,poll.current_user_responses.poll,access_rules.tier.nul"
|
||||||
|
"l"
|
||||||
|
|
||||||
"&fields[post]=change_visibility_at,comment_count,content,current_"
|
"&fields[post]=change_visibility_at,comment_count,content,current_"
|
||||||
"user_can_delete,current_user_can_view,current_user_has_liked,embe"
|
"user_can_delete,current_user_can_view,current_user_has_liked,embe"
|
||||||
|
|||||||
Reference in New Issue
Block a user