Skip to main content

Fix a few issues in my Mastodon script

ID
dc04ff9
date
2024-03-16 15:46:58+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
78ce6f6
message
Fix a few issues in my Mastodon script
changed files
1 file, 2 additions, 2 deletions

Changed files

textexpander/get_mastodon_text.py (2606) → textexpander/get_mastodon_text.py (2641)

diff --git a/textexpander/get_mastodon_text.py b/textexpander/get_mastodon_text.py
index ed499b6..718c4d7 100755
--- a/textexpander/get_mastodon_text.py
+++ b/textexpander/get_mastodon_text.py
@@ -59,14 +59,14 @@ def normalise_text(text: str) -> str:
 
 if __name__ == "__main__":
     url = subprocess.check_output(
-        ["/Users/alexwlchan/.cargo/bin/safari", "url"]
+        ["osascript", "-e", 'tell application "Safari" to get URL of document 1']
     ).decode("utf8")
 
     u = hyperlink.URL.from_text(url)
 
     # e.g. https://hachyderm.io/@djnavarro/111535929722933178
     # ~>  https://hachyderm.io/api/v1/statuses/111535929722933178
-    api_url = f"https://{u.host}/api/v1/statuses/{u.path[1]}"
+    api_url = f"https://{u.host}/api/v1/statuses/{u.path[1]}".strip()
 
     resp = httpx.get(api_url)