mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2026-05-09 11:27:36 +02:00
Idiomas
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user