mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
If one image just add it to embed
This commit is contained in:
parent
897178bb76
commit
1bf9a42ad3
|
@ -59,6 +59,9 @@ def embed_formatter(post, post_type):
|
||||||
if settings["fandom_discussions"]["appearance"]["embed"]["show_content"]:
|
if settings["fandom_discussions"]["appearance"]["embed"]["show_content"]:
|
||||||
npost = DiscussionsFromHellParser(post)
|
npost = DiscussionsFromHellParser(post)
|
||||||
embed["description"] = npost.parse()
|
embed["description"] = npost.parse()
|
||||||
|
if npost.image_only:
|
||||||
|
embed["image"]["url"] = embed["description"].strip()
|
||||||
|
embed["description"] = ""
|
||||||
elif post_type == "POLL":
|
elif post_type == "POLL":
|
||||||
poll = post["poll"]
|
poll = post["poll"]
|
||||||
embed["title"] = _("Created a poll titled \"{}\"").format(poll["question"])
|
embed["title"] = _("Created a poll titled \"{}\"").format(poll["question"])
|
||||||
|
@ -127,6 +130,7 @@ class DiscussionsFromHellParser:
|
||||||
self.jsonModal = json.loads(post.get("jsonModel", "{}"))
|
self.jsonModal = json.loads(post.get("jsonModel", "{}"))
|
||||||
self.markdown_text = ""
|
self.markdown_text = ""
|
||||||
self.item_num = 1
|
self.item_num = 1
|
||||||
|
self.image_only = False
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
"""Main parsing logic"""
|
"""Main parsing logic"""
|
||||||
|
@ -134,6 +138,8 @@ class DiscussionsFromHellParser:
|
||||||
images = {}
|
images = {}
|
||||||
for num, image in enumerate(self.post["_embedded"]["contentImages"]):
|
for num, image in enumerate(self.post["_embedded"]["contentImages"]):
|
||||||
images["img-{}".format(num)] = image["url"]
|
images["img-{}".format(num)] = image["url"]
|
||||||
|
if len(images.keys()) == 1 and self.markdown_text.strip() == "{img-0}":
|
||||||
|
self.image_only = True
|
||||||
self.markdown_text = self.markdown_text.format(**images)
|
self.markdown_text = self.markdown_text.format(**images)
|
||||||
if len(self.markdown_text) > 2000:
|
if len(self.markdown_text) > 2000:
|
||||||
self.markdown_text = self.markdown_text[0:2000] + "…"
|
self.markdown_text = self.markdown_text[0:2000] + "…"
|
||||||
|
|
Loading…
Reference in a new issue