-
Notifications
You must be signed in to change notification settings - Fork 1
/
deck_64gb_cron.py
41 lines (31 loc) · 1.09 KB
/
deck_64gb_cron.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from urllib.request import urlopen
# Set this
ntfy_url = "https://ntfy.sh/YOUR_NTFY_URL"
# We need a timeout to prevent script from hanging
timeout = 8
def parse_availability(data: bytes) -> bool:
parsed = " ".join(f"{c:02X}" for c in data)
if parsed.startswith("08 01 10 "):
return True
elif parsed.startswith("08 00 10 "):
return False
else:
raise Exception("Unknown response value")
def is_available(id: str) -> bool:
url = (
"https://api.steampowered.com/IPhysicalGoodsService/"
"CheckInventoryAvailableByPackage/v1?origin="
f"https://store.steampowered.com&input_protobuf_encoded={id}"
)
with urlopen(url, timeout=timeout) as response:
data = response.read()
return parse_availability(data)
def notify(name: str) -> None:
message = f"Version {name} is now available!"
print(message)
with urlopen(ntfy_url, data=str.encode(message), timeout=timeout):
pass
if __name__ == "__main__":
# Refurbished 64GB in Europe, tested in Poland
if is_available("COGVNxICUEw="):
notify("64GB")