Added toot deletion and opening URLS in the browser

This commit is contained in:
2022-11-09 15:52:18 -06:00
parent 7aa986163b
commit b405e384c8
2 changed files with 25 additions and 6 deletions

View File

@@ -1,5 +1,8 @@
import re
from html.parser import HTMLParser
url_re = re.compile("(?:\w+://|www\.)[^ ,.?!#%=+][^ \\n\\t]*")
class HTMLFilter(HTMLParser):
text = ""
def handle_data(self, data):
@@ -40,4 +43,7 @@ def get_media_urls(toot):
for media in toot.media_attachments:
if media.get("type") == "audio" or media.get("type") == "video":
urls.append(media.get("url"))
return urls
return urls
def find_urls(text):
return url_re.findall(html_filter(text))