Skip to content

Instantly share code, notes, and snippets.

@hostmaster
Created July 31, 2013 17:32
Show Gist options
  • Save hostmaster/6124207 to your computer and use it in GitHub Desktop.
Save hostmaster/6124207 to your computer and use it in GitHub Desktop.
A simple watcher for clipboard. Start a new download task if new magnet link detected.
#!/usr/bin/env python
#
#
import time
import re
import subprocess
import xerox
bt_cmd = "/usr/bin/qbittorrent"
recent_value = ""
while True:
tmp_value = xerox.paste()
if tmp_value != recent_value:
recent_value = tmp_value
if re.search('magnet:', recent_value):
print "Value changed: {0}".format(str(recent_value)[:20])
subprocess.call([bt_cmd, recent_value])
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment