Changed Time Interval Minute to Second
This commit is contained in:
parent
b826beb4ef
commit
9a50e545e3
21
cowin.py
21
cowin.py
|
@ -32,6 +32,7 @@ class CoWinBook():
|
||||||
# Vaccination Center id and Session id for Slot Booking
|
# Vaccination Center id and Session id for Slot Booking
|
||||||
self.vacc_center = None
|
self.vacc_center = None
|
||||||
self.vacc_session = None
|
self.vacc_session = None
|
||||||
|
self.slot_time = None
|
||||||
|
|
||||||
# Dose 1 or Dose 2 ( default : 1)
|
# Dose 1 or Dose 2 ( default : 1)
|
||||||
self.dose = dose
|
self.dose = dose
|
||||||
|
@ -186,6 +187,7 @@ class CoWinBook():
|
||||||
|
|
||||||
self.vacc_center = center.get('center_id')
|
self.vacc_center = center.get('center_id')
|
||||||
self.vacc_session = session.get("session_id")
|
self.vacc_session = session.get("session_id")
|
||||||
|
self.slot_time = session.get('slots')[0]
|
||||||
|
|
||||||
center_name = center.get('name')
|
center_name = center.get('name')
|
||||||
capacity = session.get('available_capacity')
|
capacity = session.get('available_capacity')
|
||||||
|
@ -218,6 +220,10 @@ class CoWinBook():
|
||||||
data = '{}'
|
data = '{}'
|
||||||
response = self.session.post('https://cdn-api.co-vin.in/api/v2/auth/getRecaptcha', data=data)
|
response = self.session.post('https://cdn-api.co-vin.in/api/v2/auth/getRecaptcha', data=data)
|
||||||
|
|
||||||
|
if not response.ok:
|
||||||
|
self.login_cowin()
|
||||||
|
return self.get_captcha()
|
||||||
|
|
||||||
# Get Captcha Data from Json
|
# Get Captcha Data from Json
|
||||||
svg_data = response.json()['captcha']
|
svg_data = response.json()['captcha']
|
||||||
|
|
||||||
|
@ -254,7 +260,7 @@ class CoWinBook():
|
||||||
"center_id":self.vacc_center ,
|
"center_id":self.vacc_center ,
|
||||||
"session_id":self.vacc_session,
|
"session_id":self.vacc_session,
|
||||||
"beneficiaries":self.user_id,
|
"beneficiaries":self.user_id,
|
||||||
"slot":"09:00AM-11:00AM",
|
"slot":self.slot_time,
|
||||||
"captcha": captcha,
|
"captcha": captcha,
|
||||||
"dose": self.dose
|
"dose": self.dose
|
||||||
}
|
}
|
||||||
|
@ -281,6 +287,7 @@ class CoWinBook():
|
||||||
|
|
||||||
# Set details about Vaacination Center and User Id
|
# Set details about Vaacination Center and User Id
|
||||||
def setup_details(self):
|
def setup_details(self):
|
||||||
|
|
||||||
self.select_center()
|
self.select_center()
|
||||||
self.select_beneficiaries()
|
self.select_beneficiaries()
|
||||||
|
|
||||||
|
@ -380,18 +387,24 @@ class CoWinBook():
|
||||||
self.user_id = USER_ID
|
self.user_id = USER_ID
|
||||||
|
|
||||||
|
|
||||||
def main(mobile_no,pincode, age = 18,dose = 1,time = 1,fast = None):
|
def main(mobile_no,pincode, age = 18,dose = 1,time = 30,fast = None):
|
||||||
|
|
||||||
|
# Correct Age
|
||||||
|
age = 18 if age < 45 else 45
|
||||||
|
|
||||||
|
# Max 30 Seconds
|
||||||
|
time = 30 if time > 30 else time
|
||||||
|
|
||||||
global cowin
|
global cowin
|
||||||
cowin = CoWinBook(mobile_no,pincode,age,dose)
|
cowin = CoWinBook(mobile_no,pincode,age,dose)
|
||||||
|
|
||||||
print(f" 📍 {pincode} 💉 {age}+ ⌛️ {time} Minute")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if fast:cowin.book_now()
|
if fast:cowin.book_now()
|
||||||
except SchedulerNotRunningError: return
|
except SchedulerNotRunningError: return
|
||||||
|
|
||||||
scheduler.add_job(cowin.book_now, 'cron',hour = "8-21", minute = f'0-59/{time}')
|
scheduler.add_job(cowin.book_now, 'cron', second = f'*/{time}')
|
||||||
|
print(f" 📍 {pincode} 💉 {age}+ ⌛️ {time} Seconds")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Reference in a new issue