diff --git a/find_posts.py b/find_posts.py index 37d88f5..330e5c7 100644 --- a/find_posts.py +++ b/find_posts.py @@ -478,6 +478,10 @@ def parse_user_url(url): if match is not None: return match + match = parse_pixelfed_profile_url(url) + if match is not None: + return match + log(f"Error parsing Profile URL {url}") return None @@ -493,6 +497,11 @@ def parse_url(url, parsed_urls): if match is not None: parsed_urls[url] = match + if url not in parsed_urls: + match = parse_pixelfed_url(url) + if match is not None: + parsed_urls[url] = match + if url not in parsed_urls: log(f"Error parsing toot URL {url}") parsed_urls[url] = None @@ -540,6 +549,22 @@ def parse_pleroma_profile_url(url): return (match.group("server"), match.group("username")) return None +def parse_pixelfed_url(url): + """parse a Pixelfed URL and return the server and ID""" + match = re.match( + r"https://(?P.*)/p/(?P.*)/(?P.*)", url + ) + if match is not None: + return (match.group("server"), match.group("toot_id")) + return None + +def parse_pixelfed_profile_url(url): + """parse a Pixelfed Profile URL and return the server and username""" + match = re.match(r"https://(?P.*)/(?P.*)", url) + if match is not None: + return (match.group("server"), match.group("username")) + return None + def get_redirect_url(url): """get the URL given URL redirects to"""