text: import datetime
  import os
  import sys
  
  import requests
  
  from utils.displayData import viableOptions
  
  BOOKING_URL = "https://cdn-api.co-vin.in/api/v2/appointment/schedule"
  BENEFICIARIES_URL = "https://cdn-api.co-vin.in/api/v2/appointment/beneficiaries"
  CALENDAR_URL_DISTRICT = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/calendarByDistrict?district_id={0}&date={1}"
  CALENDAR_URL_PINCODE = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/calendarByPin?pincode={0}&date={1}"
  CAPTCHA_URL = "https://cdn-api.co-vin.in/api/v2/auth/getRecaptcha"
  OTP_PUBLIC_URL = "https://cdn-api.co-vin.in/api/v2/auth/public/generateOTP"
  OTP_PRO_URL = "https://cdn-api.co-vin.in/api/v2/auth/generateMobileOTP"
  
  WARNING_BEEP_DURATION = (1000, 2000)
  
  
  try:
      import winsound
  
  except ImportError:
      import os
  
      if sys.platform == "darwin":
  
          def beep(freq, duration):
              # brew install SoX --> install SOund eXchange universal sound sample translator on mac
              os.system(f"play -n synth {duration/1000} sin {freq} >/dev/null 2>&1")
  
      else:
  
          def beep(freq, duration):
              # apt-get install beep  --> install beep package on linux distros before running
              os.system("beep -f %s -l %s" % (freq, duration))
  
  
  else:
  
      def beep(freq, duration):
          winsound.Beep(freq, duration)
  
  
  def checkCalenderByDistrict(
      request_header,
      vaccine_type,
      location_dtls,
      start_date,
      minimum_slots,
      min_age_booking,
      fee_type,
      dose,
  ):
      """
      This function
          1. Takes details required to check vaccination calendar
          2. Filters result by minimum number of slots available
          3. Returns False if token is invalid
          4. Returns list of vaccination centers & slots if available
      """
      try:
          print(
              "==================================================================================="
          )
          today = datetime.datetime.today()
          base_url = CALENDAR_URL_DISTRICT
  
          if vaccine_type:
              base_url += f"&vaccine={vaccine_type}"
  
          options = []
          for location in location_dtls:
              resp = requests.get(
                  base_url.format(location["district_id"], start_date),
                  headers=request_header,
              )
  
              if resp.status_code == 401:
                  print("TOKEN INVALID")
                  return False
  
              elif resp.status_code == 200:
                  resp = resp.json()
                  if "centers" in resp:
                      print(
                          f"Centers available in {location['district_name']} from {start_date} as of {today.strftime('%Y-%m-%d %H:%M:%S')}: {len(resp['centers'])}"
                      )
                      options += viableOptions(
                          resp, minimum_slots, min_age_booking, fee_type, dose
                      )
  
              else:
                  pass
  
          for location in location_dtls:
              if location["district_name"] in [option["district"] for option in options]:
                  for _ in range(2):
                      beep(location["alert_freq"], 150)
          return options
  
      except Exception as e:
          print(str(e))
          beep(WARNING_BEEP_DURATION[0], WARNING_BEEP_DURATION[1])
  
  
  def checkCalenderByPincode(
      request_header,
      vaccine_type,
      location_dtls,
      start_date,
      minimum_slots,
      min_age_booking,
      fee_type,
      dose,
  ):
      """
      This function
          1. Takes details required to check vaccination calendar
          2. Filters result by minimum number of slots available
          3. Returns False if token is invalid
          4. Returns list of vaccination centers & slots if available
      """
      try:
          print(
              "==================================================================================="
          )
          today = datetime.datetime.today()
          base_url = CALENDAR_URL_PINCODE
  
          if vaccine_type:
              base_url += f"&vaccine={vaccine_type}"
  
          options = []
          for location in location_dtls:
              resp = requests.get(
                  base_url.format(location["pincode"], start_date), headers=request_header
              )
  
              if resp.status_code == 401:
                  print("TOKEN INVALID")
                  return False
  
              elif resp.status_code == 200:
                  resp = resp.json()
                  if "centers" in resp:
                      print(
                          f"Centers available in {location['pincode']} from {start_date} as of {today.strftime('%Y-%m-%d %H:%M:%S')}: {len(resp['centers'])}"
                      )
                      options += viableOptions(
                          resp, minimum_slots, min_age_booking, fee_type, dose
                      )
  
              else:
                  pass
  
          for location in location_dtls:
              if int(location["pincode"]) in [option["pincode"] for option in options]:
                  for _ in range(2):
                      beep(location["alert_freq"], 150)
  
          return options
  
      except Exception as e:
          print(str(e))
          beep(WARNING_BEEP_DURATION[0], WARNING_BEEP_DURATION[1])
  