Created
January 29, 2015 20:36
-
-
Save thefinn93/5b2b9392b43b8ca01104 to your computer and use it in GitHub Desktop.
Check kimsufi's availability and emails you when they've got open slots. one argument, the sort code or identifier they use for the type of server. To get it, inspect their HTML, the <tr> has a property of data-ref with the value you need. It changes sometimes too
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
## Usage: ./getAvailability.py 150sk20 | |
## Remember to fill in that shit down there first | |
import sys | |
import json | |
import requests | |
import time | |
import smtplib | |
SMTP_USERNAME = '[email protected]' | |
SMTP_PASSWORD = 'hunter2' | |
SMTP_FROM = SMTP_USERNAME | |
SMTP_SERVER = 'mail.lol.net:587' | |
SMTP_TO = ['[email protected]', '[email protected]'] | |
INTERVAL = 60 | |
while True: | |
try: | |
availability = requests.get("https://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2").json() | |
for serverType in availability['answer']['availability']: | |
if serverType['reference'] in sys.argv or len(sys.argv) == 1: | |
for zone in serverType['zones']: | |
if zone['availability'] != "unavailable": | |
mailserver = smtplib.SMTP(SMTP_SERVER) | |
mailserver.starttls() | |
mailserver.login(SMTP_USERNAME, SMTP_PASSWOD) | |
message = "%s is %s in %s (AKA OMG KIMSUFI'S! GET EM WHILE THEY'RE HOT!!)" % (serverType['reference'], zone['availability'], zone['zone']) | |
mailserver.sendmail(SMTP_FROM, SMTP_TO, message) | |
print message | |
time.sleep(300) | |
except Exception as e: | |
print e | |
time.sleep(INTERVAL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment