-
Notifications
You must be signed in to change notification settings - Fork 0
/
cowin.py
52 lines (38 loc) · 1.54 KB
/
cowin.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
# -*- coding: utf-8 -*-
"""
Created on Fri May 28 18:45:47 2021
@author: Emmanuel
"""
# UNDER DEVELOPMENT
# REFER main.py
import json, time, playsound, os, threading, datetime
from urllib.request import Request, urlopen
class WatchTower(object):
def __init__(self, stateID = 307, ping = 7.5):
assert ping >= 5.0, "Request Limit Vioalation. Potential HTTP 429 ERROR"
self.ping = ping
self.sID = stateID
self.url = self.setURL()
def setURL(self):
l = datetime.date.today().split('-')[::-1]
date = f"{l[0]}-{l[1]}-{l[2]}"
req = [f"https://cdn-api.co-vin.in/api/v2/appointment/sessions/calendarByDistrict?district_id={self.sID}&date={date}",
f"https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id={self.sID}&date={date}"]
return req
def sendReq(url, cycle):
raw = urlopen(Request(url, headers={'User-Agent': 'Mozilla/5.0'})).read().decode()
return json.loads(raw)
def formSlot(name, j):
# # int
# self.ava = j['available_capacity']
# self.d01 = j['available_capacity_dose1']
# self.d02 = j['available_capacity_dose2']
# # str
# self.nam = name
# self.dat = j['date']
# self.age = j['min_age_limit']
# self.ava = j['available_capacity']
# self.d01 = j['available_capacity_dose1']
# self.d02 = j['available_capacity_dose2']
# self.drg = j['vaccine']
pass