-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_snapshot_appids.py
42 lines (28 loc) · 1005 Bytes
/
fetch_snapshot_appids.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
42
import requests
from disk_utils import load_json, get_snapshot_fname, save_json
def get_snapshot_url():
fname = get_snapshot_fname()
return f"https://raw.githubusercontent.com/woctezuma/steam-store-snapshots/main/{fname}"
def download_snapshot():
print('Downloading')
response = requests.get(url=get_snapshot_url())
if response.ok:
data = response.json()
save_json(data, get_snapshot_fname())
else:
print("Status code: {}".format(response.status_code))
data = {"response": {"apps": []}}
return data
def load_snapshot():
try:
data = load_json(get_snapshot_fname())
except FileNotFoundError:
data = download_snapshot()
return data
def load_snapshot_app_ids():
data = load_snapshot()
all_known_app_ids = [int(app["appid"]) for app in data["response"]["apps"]]
return all_known_app_ids
if __name__ == "__main__":
all_known_app_ids = load_snapshot_app_ids()
print(len(all_known_app_ids))