GithubHelp home page GithubHelp logo

Comments (1)

theparitoshkumar avatar theparitoshkumar commented on August 15, 2024

import requests
from pygame import mixer
from datetime import datetime, timedelta
import time

#Take essential inputs form user
age = int(input("Enter your Age : "))
pincodes = [input("Enter PIN Code: ")]
num_days = int(input("Enter number of days: "))

print_flag = 'Y'

print("Starting search for Covid vaccine slots!")

actual = datetime.today()
list_format = [actual + timedelta(days=i) for i in range(num_days)]
actual_dates = [i.strftime("%d-%m-%Y") for i in list_format]

while True:
counter = 0

for pincode in pincodes:
    for given_date in actual_dates:

        URL = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode={}&date={}".format(
            pincode, given_date)
        header = {
            'User-Agent':
            'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'
        }

        result = requests.get(URL, headers=header)

        if result.ok:
            response_json = result.json()
            if response_json["centers"]:
                if (print_flag.lower() == 'y'):
                    for center in response_json["centers"]:
                        for session in center["sessions"]:
                            if (session["min_age_limit"] <= age
                                    and session["available_capacity"] > 0):
                                print('Pincode: ' + pincode)
                                print(
                                    "Available on: {}".format(given_date))
                                print("\t", center["name"])
                                print("\t", center["block_name"])
                                print("\t Price: ", center["fee_type"])
                                print("\t Availablity : ",
                                      session["available_capacity"])

                                if (session["vaccine"] != ''):
                                    print("\t Vaccine type: ",
                                          session["vaccine"])
                                print("\n")
                                counter = counter + 1
        else:
            print("No Response!")

if counter:
    print("No Vaccination slot available!")
else:
    mixer.init()
    mixer.music.load('sound/dingdong.wav')
    mixer.music.play()
    print("Search Completed!")

dt = datetime.now() + timedelta(minutes=3)

while datetime.now() < dt:
    time.sleep(1)

from cowin-vaccine-notifier.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.