-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (40 loc) · 1.79 KB
/
main.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
43
44
45
46
47
48
from playsound import playsound
import datetime as dt
import threading
import requests
import json
import time
def fire_alarm():
playsound("imperial_alarm.mp3")
def main():
while 1:
st = time.time()
today_date = dt.date.today().strftime("%d-%m-%Y")
url = f"https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=486001&date={today_date}"
response = requests.get(url)
json_response = json.dumps(response.json(), indent=4)
json_dict = json.loads(json_response)
centers_list = json_dict["centers"]
cached_session = {}
for center in centers_list:
for session in center["sessions"]:
if session["min_age_limit"] == 45:
print(f"Checking for {center['name']} : {session['date']}")
if session["available_capacity_dose1"] > 0:
cached_session[center['name']] = {}
cached_session[center['name']]['Date'] = session['date']
cached_session[center['name']]['Doses'] = session['available_capacity_dose1']
print(f"Center Name : {center['name']}")
print(f"Date : {session['date']}")
print(f"Available Doses : {session['available_capacity_dose1']}")
print(f"Center Address : {center['address']}")
print()
else:
print(f"No slots for {session['vaccine']} at {center['name']} on {session['date']}")
print()
if cached_session != {}:
print(cached_session)
threading.Thread(target=fire_alarm).start()
time.sleep(30 - (time.time() - st))
if __name__ == '__main__':
main()