-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcowin-district-checker.py
35 lines (32 loc) · 1.37 KB
/
cowin-district-checker.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
import requests
import datetime
import json
import sys
district_id = int(sys.argv[1])
age = int(sys.argv[2])
days = int(sys.argv[3])
base = datetime.datetime.today()
date_list = [base + datetime.timedelta(days=x) for x in range(days)]
date_str = [x.strftime("%d-%m-%Y") for x in date_list]
for input_date in date_str:
url = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id={}&date={}".format(
district_id, input_date)
response = requests.get(url)
if response.ok:
result = response.json()
if result["centers"]:
print("Available on: {}".format(input_date))
for center in result["centers"]:
for session in center["sessions"]:
if session["min_age_limit"] <= age:
print("Place: ", center["name"])
print("Address: ", center["address"])
print("Zone Name: ", center["block_name"])
print("Free/Paid: ", center["fee_type"])
print("Available Capacity: ",
session["available_capacity"])
if(session["vaccine"] != ''):
print("Vaccine: ", session["vaccine"])
print("\n")
else:
print("No available slots on {}".format(input_date))