This commit is contained in:
Jesús Pavón Abián
2026-02-02 15:01:36 +01:00
parent c357ce4ae5
commit aca1e07f84
4 changed files with 87 additions and 9 deletions
+11
View File
@@ -4,9 +4,12 @@ Utility functions for Bluesky session.
"""
import logging
import re
log = logging.getLogger("sessions.blueski.utils")
url_re = re.compile(r'https?://[^\s<>\[\]()"\',]+[^\s<>\[\]()"\',.:;!?]')
def g(obj, key, default=None):
"""Helper to get attribute from dict or object."""
@@ -254,6 +257,14 @@ def find_urls(post):
if uri and uri not in urls:
urls.append(uri)
# Also search plain text for URLs using regex (fallback)
text = g(record, "text", "")
if text:
text_urls = url_re.findall(text)
for u in text_urls:
if u not in urls:
urls.append(u)
return urls