mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2026-07-07 07:51:19 +02:00
Arreglar alt y mostrar la home, que desaparecía.
This commit is contained in:
@@ -136,6 +136,11 @@ def compose_post(post, db, settings, relative_times, show_screen_names=False, sa
|
||||
if images:
|
||||
text += f" [{len(images)} {_('images')}]"
|
||||
|
||||
if etype and ("gallery" in etype):
|
||||
items = g(embed, "items", [])
|
||||
if items:
|
||||
text += f" [{len(items)} {_('images')}]"
|
||||
|
||||
if etype and ("recordWithMedia" in etype):
|
||||
media = g(embed, "media", {})
|
||||
mtype = g(media, "$type") or g(media, "py_type")
|
||||
@@ -143,6 +148,10 @@ def compose_post(post, db, settings, relative_times, show_screen_names=False, sa
|
||||
images = g(media, "images", [])
|
||||
if images:
|
||||
text += f" [{len(images)} {_('images')}]"
|
||||
elif mtype and "gallery" in mtype:
|
||||
items = g(media, "items", [])
|
||||
if items:
|
||||
text += f" [{len(items)} {_('images')}]"
|
||||
elif mtype and "external" in mtype:
|
||||
ext = g(media, "external", {})
|
||||
title = g(ext, "title", "")
|
||||
|
||||
@@ -96,6 +96,18 @@ class Session(base.baseSession):
|
||||
self.settings.write()
|
||||
except Exception:
|
||||
pass
|
||||
# Upgrade old default post templates so image descriptions are read.
|
||||
old_post_templates = (
|
||||
"$display_name, $safe_text $date.",
|
||||
"$display_name, $reply_to$safe_text $date.",
|
||||
)
|
||||
templates_cfg = self.settings.get("templates")
|
||||
if templates_cfg is not None and templates_cfg.get("post") in old_post_templates:
|
||||
templates_cfg["post"] = "$display_name, $reply_to$safe_text $image_descriptions $date."
|
||||
try:
|
||||
self.settings.write()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
log.exception("Failed to migrate legacy Blueski settings")
|
||||
|
||||
|
||||
@@ -69,9 +69,13 @@ def _extract_image_descriptions(post, record):
|
||||
mtype = _g(media, "$type") or _g(media, "py_type") or ""
|
||||
if "images" in mtype:
|
||||
return list(_g(media, "images", []) or [])
|
||||
if "gallery" in mtype:
|
||||
return list(_g(media, "items", []) or [])
|
||||
return []
|
||||
if "images" in etype:
|
||||
return list(_g(embed, "images", []) or [])
|
||||
if "gallery" in etype:
|
||||
return list(_g(embed, "items", []) or [])
|
||||
return []
|
||||
|
||||
images = []
|
||||
|
||||
@@ -78,7 +78,7 @@ def _extract_images_from_embed(embed):
|
||||
for img in (img_list or []):
|
||||
url = None
|
||||
# Try all possible URL field names
|
||||
for key in ["fullsize", "thumb", "url", "uri", "src"]:
|
||||
for key in ["fullsize", "thumb", "thumbnail", "url", "uri", "src"]:
|
||||
val = g(img, key)
|
||||
if val and isinstance(val, str) and val.startswith("http"):
|
||||
url = val
|
||||
@@ -103,12 +103,18 @@ def _extract_images_from_embed(embed):
|
||||
if "images" in etype.lower():
|
||||
images.extend(extract_images(g(embed, "images", [])))
|
||||
|
||||
# Gallery embed (app.bsky.embed.gallery or app.bsky.embed.gallery#view)
|
||||
if "gallery" in etype.lower():
|
||||
images.extend(extract_images(g(embed, "items", [])))
|
||||
|
||||
# Check in recordWithMedia wrapper
|
||||
if "recordwithmedia" in etype.lower():
|
||||
media = g(embed, "media", {})
|
||||
mtype = g(media, "$type") or g(media, "py_type") or ""
|
||||
if "images" in mtype.lower():
|
||||
images.extend(extract_images(g(media, "images", [])))
|
||||
if "gallery" in mtype.lower():
|
||||
images.extend(extract_images(g(media, "items", [])))
|
||||
|
||||
return images
|
||||
|
||||
@@ -136,6 +142,12 @@ def is_image(post):
|
||||
if images and len(images) > 0:
|
||||
return True
|
||||
|
||||
# Gallery embed
|
||||
if "gallery" in etype.lower():
|
||||
items = g(embed, "items", [])
|
||||
if items and len(items) > 0:
|
||||
return True
|
||||
|
||||
# Check in recordWithMedia wrapper
|
||||
if "recordwithmedia" in etype.lower():
|
||||
media = g(embed, "media", {})
|
||||
@@ -144,6 +156,10 @@ def is_image(post):
|
||||
images = g(media, "images", [])
|
||||
if images and len(images) > 0:
|
||||
return True
|
||||
if "gallery" in mtype.lower():
|
||||
items = g(media, "items", [])
|
||||
if items and len(items) > 0:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user