From 6aeefcb4b1ae8db28baa122f226849636c2aa761 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 14 May 2020 21:40:50 -0700 Subject: [PATCH] Add watchforlinks.py. --- watchforlinks.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 watchforlinks.py diff --git a/watchforlinks.py b/watchforlinks.py new file mode 100644 index 0000000..7c29354 --- /dev/null +++ b/watchforlinks.py @@ -0,0 +1,38 @@ +import pyperclip +import sys +import time + +from voussoirkit import passwordy + +def loop_once(): + try: + text = pyperclip.paste() + except Exception: + return + + if '\n' in text: + return + + if 'http://' in text or 'https://' in text: + fn = passwordy.urandom_hex(12) + '.generic' + pyperclip.copy('') + print(fn, text) + h = open(fn, 'w', encoding='utf-8') + h.write(text) + h.close() + +def loop_forever(): + while True: + loop_once() + time.sleep(1) + +def main(argv): + try: + loop_forever() + except KeyboardInterrupt: + pass + + return 0 + +if __name__ == '__main__': + raise SystemExit(main(sys.argv[1:]))