From aa28bd5777ebd81d56238b112c3bb0f312de4e57 Mon Sep 17 00:00:00 2001 From: Ranjan Mohanty Date: Tue, 7 May 2024 03:06:25 +0200 Subject: [PATCH] Add support for Azerbaijan-Italy VFS --- config/vfs_urls.ini | 3 ++- vfs_appointment_bot/main.py | 3 ++- vfs_appointment_bot/utils/timer.py | 2 +- vfs_appointment_bot/vfs_bot/vfs_bot_de.py | 2 +- .../vfs_bot/vfs_bot_factory.py | 6 +++--- vfs_appointment_bot/vfs_bot/vfs_bot_it.py | 21 +++++++++++-------- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/config/vfs_urls.ini b/config/vfs_urls.ini index 4263864..f3aec6c 100644 --- a/config/vfs_urls.ini +++ b/config/vfs_urls.ini @@ -1,4 +1,5 @@ [vfs-url] IN-DE = https://visa.vfsglobal.com/ind/en/deu/login IQ-DE = https://visa.vfsglobal.com/irq/en/deu/login -MA-IT = https://visa.vfsglobal.com/mar/en/ita/login \ No newline at end of file +MA-IT = https://visa.vfsglobal.com/mar/en/ita/login +AZ-IT = https://visa.vfsglobal.com/aze/en/ita/login \ No newline at end of file diff --git a/vfs_appointment_bot/main.py b/vfs_appointment_bot/main.py index 964c5c4..cd4409f 100644 --- a/vfs_appointment_bot/main.py +++ b/vfs_appointment_bot/main.py @@ -90,7 +90,8 @@ def main() -> None: if appointment_found: break countdown( - get_config_value("default", "interval"), "Next appointment check in" + int(get_config_value("default", "interval")), + "Next appointment check in", ) except (UnsupportedCountryError, LoginError) as e: diff --git a/vfs_appointment_bot/utils/timer.py b/vfs_appointment_bot/utils/timer.py index a4fc5a4..ab8d327 100644 --- a/vfs_appointment_bot/utils/timer.py +++ b/vfs_appointment_bot/utils/timer.py @@ -3,7 +3,7 @@ from tqdm import tqdm -def countdown(t, message="Countdown", unit="seconds"): +def countdown(t: int, message="Countdown", unit="seconds"): """ Implements a countdown timer diff --git a/vfs_appointment_bot/vfs_bot/vfs_bot_de.py b/vfs_appointment_bot/vfs_bot/vfs_bot_de.py index 7290743..09a03bd 100644 --- a/vfs_appointment_bot/vfs_bot/vfs_bot_de.py +++ b/vfs_appointment_bot/vfs_bot/vfs_bot_de.py @@ -33,7 +33,7 @@ def __init__(self, source_country_code: str): """ super().__init__() self.source_country_code = source_country_code - self.destination_country_code = "de" + self.destination_country_code = "DE" self.appointment_param_keys = [ "visa_center", "visa_category", diff --git a/vfs_appointment_bot/vfs_bot/vfs_bot_factory.py b/vfs_appointment_bot/vfs_bot/vfs_bot_factory.py index 14214b9..4d09151 100644 --- a/vfs_appointment_bot/vfs_bot/vfs_bot_factory.py +++ b/vfs_appointment_bot/vfs_bot/vfs_bot_factory.py @@ -23,13 +23,13 @@ def get_vfs_bot(source_country_code: str, destination_country_code: str) -> VfsB UnsupportedCountryError: If the provided country is not supported. """ - country_lower = destination_country_code.lower() + country_lower = destination_country_code - if country_lower == "de": + if country_lower == "DE": from .vfs_bot_de import VfsBotDe return VfsBotDe(source_country_code) - elif country_lower == "it": + elif country_lower == "IT": from .vfs_bot_it import VfsBotIt return VfsBotIt(source_country_code) diff --git a/vfs_appointment_bot/vfs_bot/vfs_bot_it.py b/vfs_appointment_bot/vfs_bot/vfs_bot_it.py index d06aa0f..3081df0 100644 --- a/vfs_appointment_bot/vfs_bot/vfs_bot_it.py +++ b/vfs_appointment_bot/vfs_bot/vfs_bot_it.py @@ -33,14 +33,16 @@ def __init__(self, source_country_code: str): """ super().__init__() self.source_country_code = source_country_code - self.destination_country_code = "it" + self.destination_country_code = "IT" self.appointment_param_keys = [ "visa_center", "visa_category", "visa_sub_category", - "payment_mode", ] + if self.source_country_code == "MA": + self.appointment_param_keys.append("payment_mode") + def login(self, page: Page, email_id: str, password: str) -> None: """ Performs login steps specific to the Italy VFS website. @@ -127,13 +129,14 @@ def check_for_appontment( ) visa_subcategory_dropdown_option.click() - # Select Payment Mode - payment_mode_dropdown = page.query_selector_all("mat-form-field")[3] - payment_mode_dropdown.click() - payment_mode_dropdown_option = page.wait_for_selector( - f'mat-option:has-text("{appointment_params.get("payment_mode")}")' - ) - payment_mode_dropdown_option.click() + if self.source_country_code == "MA": + # Select Payment Mode + payment_mode_dropdown = page.query_selector_all("mat-form-field")[3] + payment_mode_dropdown.click() + payment_mode_dropdown_option = page.wait_for_selector( + f'mat-option:has-text("{appointment_params.get("payment_mode")}")' + ) + payment_mode_dropdown_option.click() try: page.wait_for_selector("div.alert")