Created
October 30, 2024 22:10
-
-
Save j2kun/a8f5c5a8d3d56b1f1bb98e948254a944 to your computer and use it in GitHub Desktop.
webmention utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import indieweb_utils | |
def send_webmention(source_url, target_url, dry_run=False): | |
print(f"Found a webmention: {source_url} -> {target_url}") | |
try: | |
indieweb_utils.discover_webmention_endpoint(source_url) | |
except Exception as e: | |
print(f"Error discovering webmention endpoint: {e}") | |
return | |
if dry_run: | |
print("Dry run enabled, skipping webmention") | |
return | |
try: | |
response = indieweb_utils.send_webmention(source_url, target_url) | |
except indieweb_utils.webmentions.discovery.WebmentionEndpointNotFound: | |
print("Webmention endpoint not found.") | |
return | |
except Exception as e: | |
print(f"Webmention error: {e}") | |
return | |
print(response) | |
print("Webmention sent!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment