Created
August 6, 2024 01:47
-
-
Save 0xOsprey/2be68e0559add37c459978f63140d873 to your computer and use it in GitHub Desktop.
Archive.is Opener - Raycast Script
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
#!/usr/bin/python3 | |
# Required parameters: | |
# @raycast.schemaVersion 1 | |
# @raycast.title Archive Opener | |
# @raycast.mode compact | |
# Optional parameters: | |
# @raycast.icon 🤖 | |
# Documentation: | |
# @raycast.description Open copied urls on Archive.is to help remove paywalls | |
# @raycast.author Joe Coll | |
# @raycast.authorURL https://raycast.com/Osprey | |
import pyperclip, webbrowser | |
from urllib.parse import urlparse | |
def is_valid_url(url): | |
try: | |
result = urlparse(url) | |
return all([result.scheme, result.netloc]) | |
except ValueError: | |
return False | |
# Check if the clipboard content is a valid URL | |
if is_valid_url(pyperclip.paste()): | |
webbrowser.open(f"https://archive.is/{pyperclip.paste()}") | |
else: | |
print("Invalid URL in clipboard") | |
exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment