Want more features on Pastebin? Sign Up, it's FREE!
Guest

check.py

By: DoctorNick on Nov 29th, 2013  |  syntax: Python  |  size: 1.40 KB  |  views: 2,495  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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"
  7.  
  8. import requests, time
  9. import pushnotify
  10. from pushnotify import get_client
  11. from crontab import CronTab
  12.  
  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='https://dognzb.cr/register', 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)
  20.  
  21. r = requests.get('https://dognzb.cr/register', 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 ~/check.py'
  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()
clone this paste RAW Paste Data