Last active
August 4, 2021 15:46
-
-
Save kandulaganesh/728374fe6ba29b140f97e02c56e4e02d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from playsound import playsound | |
import sys | |
import time | |
import pytz | |
from datetime import datetime | |
subscribed_centers=["Bus Depo Buharanpuram Khammam","Rica Bazar High School KMM","Musthafanagar UPHC"] | |
search_dates=["31-05-2021","01-06-2021","02-06-2021"] | |
def handleSubscribedCenter(vaccine_data_in_center): | |
sessions=vaccine_data_in_center["sessions"] | |
for session in sessions: | |
available_capacity_dose1=session["available_capacity_dose1"] | |
available_capacity=session["available_capacity"] | |
age_limit=session["min_age_limit"] | |
if age_limit == 18 and ( available_capacity > 0 or available_capacity_dose1 > 0 ): | |
print("Availabe") | |
music_path="/Users/kandula/bass_music.mp3" | |
playsound(music_path) | |
else: | |
print("Not Found") | |
def handleCenters(vaccine_data_in_all_centers): | |
centers=vaccine_data_in_all_centers["centers"] | |
for center in centers: | |
center_name=center["name"] | |
if center_name in subscribed_centers: | |
handleSubscribedCenter(center) | |
while True: | |
for s_date in search_dates: | |
api="https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict" | |
query={"district_id":590,"date":s_date} | |
response = requests.get(api,params=query) | |
status_code=response.status_code | |
if status_code == 200: | |
data=response.json() | |
handleCenters(data) | |
else: | |
print("Status code is ",status_code) | |
print("Sleeping...") | |
time.sleep(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment