Created
May 27, 2021 17:19
-
-
Save akhilerm/365dd94ea57c11f49dbbd4c13e8490cd to your computer and use it in GitHub Desktop.
cowin slot
This file contains 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 os | |
import requests | |
import json | |
import datetime | |
import time | |
import sys | |
url = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict" | |
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"} | |
def sound(): | |
for _ in range(10): | |
os.system('play -nq -t alsa synth 1 sine 440') | |
time.sleep(1) | |
def main(argv): | |
district_id = argv[1] | |
age_limit = int(argv[2]) | |
while(1): | |
d = datetime.date.today().strftime("%d-%m-%y") | |
param = {"district_id":district_id,"date":d} | |
resp = requests.get(url, params=param, headers=headers) | |
try: | |
data = resp.json() | |
except Exception as e: | |
print('JSON Decode error', e) | |
continue | |
for center in data["centers"]: | |
for session in center["sessions"]: | |
if(int(session["available_capacity_dose1"])>0 and int(session["min_age_limit"])==age_limit): | |
print(center['address']) | |
print('Dose1 available', session["available_capacity_dose1"]) | |
sound() | |
time.sleep(10) | |
if __name__ == "__main__": | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script checks only for dose1 availability, and plays a sound using
sox
.Install sox using
Run