-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathscript.py
67 lines (52 loc) · 2.34 KB
/
script.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'''
Script: Covid Vaccine Slot Availability Notifier
By Ayushi Rawat
'''
import requests
from pygame import mixer
from datetime import datetime, timedelta
import time
age = 52
pincodes = ["462003"]
num_days = 2
print_flag = 'Y'
print("Starting search for Covid vaccine slots!")
actual = datetime.today()
list_format = [actual + timedelta(days=i) for i in range(num_days)]
actual_dates = [i.strftime("%d-%m-%Y") for i in list_format]
while True:
counter = 0
for pincode in pincodes:
for given_date in actual_dates:
URL = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode={}&date={}".format(pincode, given_date)
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'}
result = requests.get(URL, headers=header)
if result.ok:
response_json = result.json()
if response_json["centers"]:
if(print_flag.lower() =='y'):
for center in response_json["centers"]:
for session in center["sessions"]:
if (session["min_age_limit"] <= age and session["available_capacity"] > 0 ) :
print('Pincode: ' + pincode)
print("Available on: {}".format(given_date))
print("\t", center["name"])
print("\t", center["block_name"])
print("\t Price: ", center["fee_type"])
print("\t Availablity : ", session["available_capacity"])
if(session["vaccine"] != ''):
print("\t Vaccine type: ", session["vaccine"])
print("\n")
counter = counter + 1
else:
print("No Response!")
if counter:
print("No Vaccination slot available!")
else:
mixer.init()
mixer.music.load('sound/dingdong.wav')
mixer.music.play()
print("Search Completed!")
dt = datetime.now() + timedelta(minutes=3)
while datetime.now() < dt:
time.sleep(1)