Files
exposedgays/deploy/godaddy-exposedgays.py

42 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Check GoDaddy domain status for exposedgays.com."""
import json
import urllib.error
import urllib.request
KEY = "2wYVpc3VT4_Gi9AsNqzJ6BtSfNz6nLDuo"
SECRET = "NvC3qexGAU7Rd5QExUTH6z"
DOMAIN = "exposedgays.com"
BASE = "https://api.godaddy.com/v1"
def gd(path, method="GET", body=None):
req = urllib.request.Request(
BASE + path,
data=json.dumps(body).encode() if body else None,
method=method,
headers={
"Authorization": f"sso-key {KEY}:{SECRET}",
"Content-Type": "application/json",
"Accept": "application/json",
},
)
try:
with urllib.request.urlopen(req, timeout=45) as r:
return r.status, json.load(r)
except urllib.error.HTTPError as e:
try:
return e.code, json.loads(e.read().decode())
except Exception:
return e.code, {"raw": e.read().decode()[:500]}
for path in [
f"/domains/{DOMAIN}",
f"/domains/{DOMAIN}/records",
f"/domains/{DOMAIN}/records/A",
f"/domains/{DOMAIN}/records/CNAME",
]:
code, res = gd(path)
print(f"\n{path} -> HTTP {code}")
print(json.dumps(res, indent=2)[:3000])