Add watchforlinks.py.

This commit is contained in:
voussoir 2020-05-14 21:40:50 -07:00
parent 123f475d65
commit 6aeefcb4b1

38
watchforlinks.py Normal file
View file

@ -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:]))