diff --git a/CovidVaccineChecker/__init__.py b/CovidVaccineChecker/__init__.py index 37ab005..d5e4ca4 100644 --- a/CovidVaccineChecker/__init__.py +++ b/CovidVaccineChecker/__init__.py @@ -1,6 +1,6 @@ import os import re -# import sys +from sys import exit import json import time import random @@ -10,7 +10,7 @@ from inspect import stack from hashlib import sha256 import PySimpleGUI as simpleGUI -from CovidVaccineChecker.captcha import captcha_builder +# from CovidVaccineChecker.captcha import captcha_builder def getCallingScriptFilename(): @@ -285,7 +285,7 @@ def create_new_user_config(self, user_config_file): f"at that centre only. You can still enter a centre's name below as your preference as there might be other sessions as well in " f"the same centre with different 'Min Age, Available Capacity and Slots' value.{TextColors.ENDC}") centre_preferences = input(f"\n-->\tEnter short/full centre name for centre preference " - f"{TextColors.WARNING}(comma-separated in case of multiple){TextColors.ENDC}: ") + f"{TextColors.WARNING}(comma-separated in case of multiple), CAN BE BLANK AS WELL{TextColors.ENDC}: ") if centre_preferences is not None and centre_preferences.strip() != "": self.centre_preferences = centre_preferences.strip().replace(', ', ',').replace(' ,', ',').lower().split(",") @@ -678,25 +678,25 @@ def get_appointment_details(appointment_dict): return appointment_details - def generate_captcha(self, user_config_file, is_app_gui): - print(f"\n{TextColors.HEADER}============================= GENERATING CAPTCHA ============================={TextColors.ENDC}") - - while True: - response = requests.request("POST", self.captcha_url, headers=self.auth_headers) - - if response.status_code == 200: - print(f"\nCAPTCHA GENERATED!!!") - # with open("response_captcha.json", "w") as captcha_json_file: - # captcha_json_file.write(json.dumps(response.json(), indent=4)) - return captcha_builder(response.json()) - else: - if "unauthenticated access" in response.text.lower(): - if is_app_gui: - return '' - self.generateUserToken(user_config_file, refresh_token=True) - else: - print(f"\n{TextColors.FAIL}FAILED ATTEMPT (message: could not generate captcha){TextColors.ENDC} (response: {response.text})... trying again in 1 sec.") - time.sleep(1) + # def generate_captcha(self, user_config_file, is_app_gui): + # print(f"\n{TextColors.HEADER}============================= GENERATING CAPTCHA ============================={TextColors.ENDC}") + # + # while True: + # response = requests.request("POST", self.captcha_url, headers=self.auth_headers) + # + # if response.status_code == 200: + # print(f"\nCAPTCHA GENERATED!!!") + # # with open("response_captcha.json", "w") as captcha_json_file: + # # captcha_json_file.write(json.dumps(response.json(), indent=4)) + # return captcha_builder(response.json()) + # else: + # if "unauthenticated access" in response.text.lower(): + # if is_app_gui: + # return '' + # self.generateUserToken(user_config_file, refresh_token=True) + # else: + # print(f"\n{TextColors.FAIL}FAILED ATTEMPT (message: could not generate captcha){TextColors.ENDC} (response: {response.text})... trying again in 1 sec.") + # time.sleep(1) def isValidCentre(self, centre, min_age_limit): @@ -741,12 +741,12 @@ def schedule_appointment(self, all_centres, ref_ids, dose_number, min_age_limit, if self.isValidCentre(centre, min_age_limit) or dummy_centre_check: print(f"{TextColors.BOLD}{TextColors.WARNING}(VALID CENTRE FOUND - Booking Appointment...){TextColors.ENDC}") if centre['available_capacity_dose'+str(dose_number)] >= len(ref_ids): - captcha = self.generate_captcha(user_config_file, is_app_gui) - - if captcha == '' and is_app_gui: - return False, '' - - print(f"\n{TextColors.BLACKONGREY}Entered Captcha Value: {captcha}{TextColors.ENDC}") + # captcha = self.generate_captcha(user_config_file, is_app_gui) + # + # if captcha == '' and is_app_gui: + # return False, '' + # + # print(f"\n{TextColors.BLACKONGREY}Entered Captcha Value: {captcha}{TextColors.ENDC}") payload = json.dumps({ "dose": dose_number, @@ -755,7 +755,7 @@ def schedule_appointment(self, all_centres, ref_ids, dose_number, min_age_limit, # "slot": self.slot_preference, "slot": self.getUserSlotPreference(centre) if not is_app_gui else self.getUserSlotPreferencePopup(centre), "beneficiaries": ref_ids, - "captcha": captcha + # "captcha": captcha }) response = requests.request("POST", self.schedule_url, headers=self.auth_headers, data=payload) diff --git a/CovidVaccineChecker/captcha.py b/CovidVaccineChecker/captcha.py deleted file mode 100644 index 7cf6ae4..0000000 --- a/CovidVaccineChecker/captcha.py +++ /dev/null @@ -1,68 +0,0 @@ -# from svglib.svglib import svg2rlg -# from reportlab.graphics import renderPM -import PySimpleGUI as simpleGUI -import re -# import os -from PIL import Image -from cairosvg import svg2png -# from anticaptchaofficial.imagecaptcha import imagecaptcha - -captcha_svgFile = './captcha/captcha.svg' -captcha_pngFile = './captcha/captcha.png' -captcha_gifFile = './captcha/captcha.gif' -convert_utility = './utilities/convert.exe' - - -def captcha_builder(resp): - # with open(captcha_svgFile, 'w') as f: - # f.write(re.sub('()', '', resp['captcha'])) - - # drawing = svg2rlg(captcha_svgFile) - # renderPM.drawToFile(drawing, captcha_pngFile, fmt="PNG") - # im = Image.open(captcha_pngFile) - # im = im.convert('RGB').convert('P', palette=Image.ADAPTIVE) - # im.save(captcha_gifFile) - - # command = f'"{convert_utility}" "{captcha_svgFile}" "{captcha_gifFile}"' - # # print(f"command: {command}") - # proc = os.popen(command).read() - - captcha_svg_code = re.sub('()', '', resp['captcha']) - svg2png(bytestring=captcha_svg_code, write_to=captcha_pngFile) - im = Image.open(captcha_pngFile) - white_bg = Image.new("RGB", im.size, (255, 255, 255)) - white_bg.paste(im, im) - white_bg.save(captcha_gifFile) - - layout = [[simpleGUI.Image(captcha_gifFile)], - [simpleGUI.Text("Enter Captcha Below")], - [simpleGUI.Input(key='input')], - [simpleGUI.Button('Submit', bind_return_key=True)]] - - window = simpleGUI.Window('Enter Captcha', layout, finalize=True) - window.TKroot.focus_force() # focus on window - window.Element('input').SetFocus() # focus on field - event, values = window.read() - window.close() - return values['input'] if values else " " - - -# def captcha_builder_auto(resp, api_key): -# with open('captcha.svg', 'w') as f: -# f.write(re.sub('()', '', resp['captcha'])) -# -# drawing = svg2rlg('captcha.svg') -# renderPM.drawToFile(drawing, "captcha.png", fmt="PNG") -# -# -# solver = imagecaptcha() -# solver.set_verbose(1) -# solver.set_key(api_key) -# captcha_text = solver.solve_and_return_solution("captcha.png") -# -# if captcha_text != 0: -# print(f"Captcha text: {captcha_text}") -# else: -# print(f"Task finished with error: {solver.error_code}") -# -# return captcha_text diff --git a/README.md b/README.md index e2f46ae..0104065 100644 --- a/README.md +++ b/README.md @@ -139,10 +139,14 @@ As it's a difficult task to schedule an appointment for CoVid-Vaccine with only ```sh pip install -r requirements.txt ``` -6. Run the script to enter your details and book a vaccination slot +6. Run the script **(Console App)** to enter your details and book a vaccination slot ```sh python schedule_vaccination_appointment.py ``` +7. Run the following command for **GUI version of the App** + ```sh + python scheduler_form.py + ``` @@ -150,7 +154,7 @@ As it's a difficult task to schedule an appointment for CoVid-Vaccine with only ### Installation (via EXE file) -1. Navigate to the **'dist'** directory for the setup file or click [here](https://github.com/DivAgicha/CoWIN-Vaccine-Appointment-Booking/raw/master/dist/CovidVaccinationAppointmentScheduler-Setup-v2.0.exe) to download the same for Windows. +1. Navigate to the **'dist'** directory for the setup file or click [here](https://github.com/DivAgicha/CoWIN-Vaccine-Appointment-Booking/raw/master/dist/CovidVaccinationAppointmentScheduler-Setup-v2.1.exe) to download the same for Windows. 2. Double-click the installer file and follow the instructions to install the program. 3. Upon successful installation you will find `Covid Vaccination Appointment Scheduler` folder in your `C:\Program Files (x86)\` directory. 4. Open the folder and run `schedule_vaccination_appointment.exe` (Console App) or `scheduler_form.exe` (GUI App) file. diff --git a/dist/CovidVaccinationAppointmentScheduler-Setup-v2.0.exe b/dist/CovidVaccinationAppointmentScheduler-Setup-v2.1.exe similarity index 56% rename from dist/CovidVaccinationAppointmentScheduler-Setup-v2.0.exe rename to dist/CovidVaccinationAppointmentScheduler-Setup-v2.1.exe index fce0a54..9efc0a4 100644 Binary files a/dist/CovidVaccinationAppointmentScheduler-Setup-v2.0.exe and b/dist/CovidVaccinationAppointmentScheduler-Setup-v2.1.exe differ diff --git a/requirements.txt b/requirements.txt index a99f7bb..570f363 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,7 @@ -cairocffi==1.2.0 -CairoSVG==2.5.2 -certifi==2020.12.5 -cffi==1.14.5 +certifi==2021.5.30 chardet==4.0.0 -cssselect2==0.4.1 -defusedxml==0.7.1 idna==2.10 -Pillow==8.2.0 -pycparser==2.20 PySimpleGUI==4.43.0 requests==2.25.1 tabulate==0.8.9 -tinycss2==1.1.0 -urllib3==1.26.4 -webencodings==0.5.1 +urllib3==1.26.5 diff --git a/schedule_vaccination_appointment.py b/schedule_vaccination_appointment.py index 7e078a0..9b6247d 100644 --- a/schedule_vaccination_appointment.py +++ b/schedule_vaccination_appointment.py @@ -35,8 +35,8 @@ if not os.path.exists(os.path.join(cowinAPI.BASE_PROJECT_DIR, "user_data/")): os.makedirs(os.path.join(cowinAPI.BASE_PROJECT_DIR, "user_data/")) -if not os.path.exists(os.path.join(cowinAPI.BASE_PROJECT_DIR, "captcha/")): - os.makedirs(os.path.join(cowinAPI.BASE_PROJECT_DIR, "captcha/")) +# if not os.path.exists(os.path.join(cowinAPI.BASE_PROJECT_DIR, "captcha/")): +# os.makedirs(os.path.join(cowinAPI.BASE_PROJECT_DIR, "captcha/")) user_config_file = os.path.join(cowinAPI.BASE_PROJECT_DIR, "user_data/user_config_" + mobile + ".json") @@ -166,10 +166,13 @@ print(f"\n-->\tAttempting to book appointment {TextColors.WARNING}(every 3 seconds for next 4 minutes, i.e., total 80 attempts)" f"{TextColors.ENDC}") +# input(f"\n{TextColors.BOLD}Note: keep an eye on the screen when the process starts, as when a valid centre " +# f"gets available you will be asked to enter {TextColors.WARNING}captcha{TextColors.ENDC} {TextColors.BOLD}and select " +# f"{TextColors.WARNING}time slot{TextColors.ENDC} {TextColors.BOLD}to book and confirm the appointment{TextColors.ENDC}" +# f"\n\nPress 'Enter' to continue...") input(f"\n{TextColors.BOLD}Note: keep an eye on the screen when the process starts, as when a valid centre " - f"gets available you will be asked to enter {TextColors.WARNING}captcha{TextColors.ENDC} {TextColors.BOLD}and select " - f"{TextColors.WARNING}time slot{TextColors.ENDC} {TextColors.BOLD}to book and confirm the appointment{TextColors.ENDC}" - f"\n\nPress 'Enter' to continue...") + f"gets available you will be asked to select a {TextColors.WARNING}time slot{TextColors.ENDC} " + f"{TextColors.BOLD}to book and confirm the appointment{TextColors.ENDC}\n\nPress 'Enter' to continue...") all_centres = cowinAPI.findCentresBySearchCriteria() diff --git a/scheduler_form.py b/scheduler_form.py index ae60056..0751083 100644 --- a/scheduler_form.py +++ b/scheduler_form.py @@ -90,9 +90,9 @@ def create_window(finalize=False): simpleGUI.Button('Next', key='next_min_age_limit')] ])], - [simpleGUI.Text('Made with ♥ (https://github.com/divagicha/\nCoWIN-Vaccine-Appointment-Booking)', auto_size_text=True, font='Courier 8'), + [simpleGUI.Text('Made with ' + u'\u2665' + ' (https://github.com/divagicha/\nCoWIN-Vaccine-Appointment-Booking)', auto_size_text=True, font='Courier 8'), simpleGUI.Button('Reset Form', key='clear_values', tooltip="This will clear all the above values", size=(11, 1), button_color='Yellow'), - simpleGUI.Exit('Exit', size=(11, 1), button_color='Yellow')]] + simpleGUI.Exit('Exit', size=(11, 1), button_color='Yellow', pad=(10,0))]] colR1C2 = [[simpleGUI.Frame('Output', font='Any 8', layout=[ [simpleGUI.Output(size=(80, 35), key='console_output', font='Courier 10', echo_stdout_stderr=True)] @@ -198,9 +198,12 @@ def isInputFieldActive(key): def attempt_to_schedule_appointment(): global next_operation, attempts, all_centres + # simpleGUI.popup("Attempting to schedule appointment (every 3 seconds for next 4 minutes, i.e., total 80 attempts)\n\nNote: keep an " + # "eye on the screen when the process starts, as when a valid centre gets available you will be asked to enter CAPTCHA " + # "and select TIME SLOT to book and confirm your appointment", title="Scheduling Your Appointment") simpleGUI.popup("Attempting to schedule appointment (every 3 seconds for next 4 minutes, i.e., total 80 attempts)\n\nNote: keep an " - "eye on the screen when the process starts, as when a valid centre gets available you will be asked to enter CAPTCHA " - "and select TIME SLOT to book and confirm your appointment", title="Scheduling Your Appointment") + "eye on the screen when the process starts, as when a valid centre gets available you will be asked to select a " + "TIME SLOT to book and confirm your appointment", title="Scheduling Your Appointment") all_centres = cowinAPI.findCentresBySearchCriteria() @@ -323,8 +326,8 @@ def call_schedule_appointment(): if not os.path.exists(os.path.join(cowinAPI.BASE_PROJECT_DIR, "user_data/")): os.makedirs(os.path.join(cowinAPI.BASE_PROJECT_DIR, "user_data/")) - if not os.path.exists(os.path.join(cowinAPI.BASE_PROJECT_DIR, "captcha/")): - os.makedirs(os.path.join(cowinAPI.BASE_PROJECT_DIR, "captcha/")) + # if not os.path.exists(os.path.join(cowinAPI.BASE_PROJECT_DIR, "captcha/")): + # os.makedirs(os.path.join(cowinAPI.BASE_PROJECT_DIR, "captcha/")) key_list = list(window.key_dict.keys()) keys_to_remove = ['col1', 'col2', 'console_output', 'clear_values', 'Exit'] diff --git a/utilities/convert.exe b/utilities/convert.exe deleted file mode 100644 index fe430d3..0000000 Binary files a/utilities/convert.exe and /dev/null differ diff --git a/utilities/delegates.xml b/utilities/delegates.xml deleted file mode 100644 index ace87e9..0000000 --- a/utilities/delegates.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - -]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -