From b78d4fe32a8231eeb193d4d6f2f3bd15b354aa33 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 --- README.md | 11 +++++----- 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 +++++++++++-------- 7 files changed, 27 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ab29b86..e93d8e1 100644 --- a/README.md +++ b/README.md @@ -197,11 +197,12 @@ It currently supports three notification channels to keep you informed about app The following table lists currently supported countries and their corresponding appointment parameters: -| Country | Appointment Parameters | -| ----------------------- | ----------------------------------------------------------- | -| India(IN) - Germany(DE) | visa_category, visa_sub_category, visa_center | -| Iraq(IQ) - Germany(DE) | visa_category, visa_sub_category, visa_center | -| Morocco(MA) - Italy(IT) | visa_category, visa_sub_category, visa_center, payment_mode | +| Country | Appointment Parameters | +| -------------------------- | ----------------------------------------------------------- | +| India(IN) - Germany(DE) | visa_category, visa_sub_category, visa_center | +| Iraq(IQ) - Germany(DE) | visa_category, visa_sub_category, visa_center | +| Morocco(MA) - Italy(IT) | visa_category, visa_sub_category, visa_center, payment_mode | +| Azerbaijan(AZ) - Italy(IT) | visa_category, visa_sub_category, visa_center | **Notes:** 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")