DoctorNick Nov 29th, 2013 2,785 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. #Put this in the root of your home directory
  3. #put this in crontab, set it to like every *30* minutes (it'll blacklist you for hammering if you don't)
  4. #this uses pushover. It's 5 bucks on the app store, but it's worth it.
  5. #you need to install the python-crontab and pushnotify python packages for this script.
  6. #just do "pip install python-crontab" and "pip install pushnotify"
  8. import requests, time
  9. import pushnotify
  10. from pushnotify import get_client
  11. from crontab import CronTab
  13. #this sets it to ALERT priority, which means that it'll keep bugging you every 30 seconds until you acknowledge
  14. blag = dict(priority=2, retry=30, expire=86399, url='', url_title='register link')
  15. #put your pushover api key here.
  16. apikey = 'YOUR API KEY GOES HERE'
  17. #put your app api key here.
  18. client = get_client('pushover', 'YOUR APP API KEY GOES HERE', 'dognzb notify')
  19. client.add_key(apikey)
  21. r = requests.get('', allow_redirects=False)
  22. if (r.status_code == 200):
  23.         client.notify('DogNZB Registration open!', 'ITS OPEN!!!!!!!!!!!', split=True, kwargs=blag)
  24.         #put the command you used when you first installed this in crontab
  25.         cmd = 'python ~/'
  26.         #replace this with your username
  27.         tab = CronTab(user='nick')
  28.         cron_job = tab.find_command(cmd)
  29.         if len(cron_job) > 0:
  30.                 tab.remove_all(cmd)
  31.         #removes the job from cron once it notifies you
  32.         tab.write()
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!