[pillowfort] add 'external' option (#846)

for links to external Twitter posts etc.
pull/1578/head
Mike Fährmann 3 years ago
parent 394fbb5f56
commit efa6cc8ec3
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1306,6 +1306,16 @@ Description
Download subalbums. Download subalbums.
extractor.pillowfort.external
-----------------------------
Type
``bool``
Default
``false``
Description
Follow links to external sites, e.g. Twitter,
extractor.pillowfort.reblogs extractor.pillowfort.reblogs
---------------------------- ----------------------------
Type Type

@ -176,6 +176,7 @@
}, },
"pillowfort": "pillowfort":
{ {
"external": false,
"reblogs": false "reblogs": false
}, },
"pinterest": "pinterest":

@ -26,12 +26,13 @@ class PillowfortExtractor(Extractor):
def __init__(self, match): def __init__(self, match):
Extractor.__init__(self, match) Extractor.__init__(self, match)
self.item = match.group(1) self.item = match.group(1)
self.reblogs = self.config("reblogs", False)
def items(self): def items(self):
for post in self.posts(): reblogs = self.config("reblogs", False)
external = self.config("external", False)
if "original_post" in post and not self.reblogs: for post in self.posts():
if "original_post" in post and not reblogs:
continue continue
files = post["media"] files = post["media"]
@ -44,69 +45,86 @@ class PillowfortExtractor(Extractor):
post["num"] = 0 post["num"] = 0
for file in files: for file in files:
url = file["url"] url = file["url"]
if url: if not url:
post.update(file) continue
if file.get("embed_code"):
if not external:
continue
msgtype = Message.Queue
else:
post["num"] += 1 post["num"] += 1
post["date"] = text.parse_datetime( msgtype = Message.Url
file["created_at"], "%Y-%m-%dT%H:%M:%S.%f%z")
yield Message.Url, url, text.nameext_from_url(url, post) post.update(file)
post["date"] = text.parse_datetime(
file["created_at"], "%Y-%m-%dT%H:%M:%S.%f%z")
yield msgtype, url, text.nameext_from_url(url, post)
class PillowfortPostExtractor(PillowfortExtractor): class PillowfortPostExtractor(PillowfortExtractor):
"""Extractor for a single pillowfort post""" """Extractor for a single pillowfort post"""
subcategory = "post" subcategory = "post"
pattern = BASE_PATTERN + r"/posts/(\d+)" pattern = BASE_PATTERN + r"/posts/(\d+)"
test = ("https://www.pillowfort.social/posts/27510", { test = (
"pattern": r"https://img\d+\.pillowfort\.social/posts/\w+_out\d+\.png", ("https://www.pillowfort.social/posts/27510", {
"count": 4, "pattern": r"https://img\d+\.pillowfort\.social"
"keyword": { r"/posts/\w+_out\d+\.png",
"avatar_url": str, "count": 4,
"col": 0, "keyword": {
"commentable": True, "avatar_url": str,
"comments_count": int, "col": 0,
"community_id": None, "commentable": True,
"content": str, "comments_count": int,
"created_at": str, "community_id": None,
"date": "type:datetime", "content": str,
"deleted": None, "created_at": str,
"deleted_at": None, "date": "type:datetime",
"deleted_by_mod": None, "deleted": None,
"deleted_for_flag_id": None, "deleted_at": None,
"embed_code": None, "deleted_by_mod": None,
"id": int, "deleted_for_flag_id": None,
"last_activity": str, "embed_code": None,
"last_activity_elapsed": str, "id": int,
"last_edited_at": None, "last_activity": str,
"likes_count": int, "last_activity_elapsed": str,
"media_type": "picture", "last_edited_at": None,
"nsfw": False, "likes_count": int,
"num": int, "media_type": "picture",
"original_post_id": None, "nsfw": False,
"original_post_user_id": None, "num": int,
"picture_content_type": None, "original_post_id": None,
"picture_file_name": None, "original_post_user_id": None,
"picture_file_size": None, "picture_content_type": None,
"picture_updated_at": None, "picture_file_name": None,
"post_id": 27510, "picture_file_size": None,
"post_type": "picture", "picture_updated_at": None,
"privacy": "public", "post_id": 27510,
"reblog_copy_info": list, "post_type": "picture",
"rebloggable": True, "privacy": "public",
"reblogged_from_post_id": None, "reblog_copy_info": list,
"reblogged_from_user_id": None, "rebloggable": True,
"reblogs_count": int, "reblogged_from_post_id": None,
"row": int, "reblogged_from_user_id": None,
"small_image_url": None, "reblogs_count": int,
"tags": list, "row": int,
"time_elapsed": str, "small_image_url": None,
"timestamp": str, "tags": list,
"title": "What is Pillowfort.io? ", "time_elapsed": str,
"updated_at": str, "timestamp": str,
"url": r"re:https://img3.pillowfort.social/posts/.*\.png", "title": "What is Pillowfort.io? ",
"user_id": 5, "updated_at": str,
"username": "Staff" "url": r"re:https://img3.pillowfort.social/posts/.*\.png",
}, "user_id": 5,
}) "username": "Staff"
},
}),
("https://www.pillowfort.social/posts/1557500", {
"options": (("external", True),),
"pattern": r"https://twitter\.com/Aliciawitdaart/status"
r"/1282862493841457152",
}),
)
def posts(self): def posts(self):
url = "{}/posts/{}/json/".format(self.root, self.item) url = "{}/posts/{}/json/".format(self.root, self.item)

Loading…
Cancel
Save