fix: detect payment form and wait or user input (#520)

Co-authored-by: Jens Bergmann <1742418+1cu@users.noreply.github.com>
This commit is contained in:
Heavenfighter
2025-06-10 15:51:59 +02:00
committed by GitHub
parent a5603e742f
commit 4d48427234
4 changed files with 91 additions and 37 deletions

View File

@@ -656,7 +656,6 @@ class KleinanzeigenBot(WebScrapingMixin):
@param ad_cfg_orig: the ad config as present in the YAML file
@param published_ads: json list of published ads
"""
await self.assert_free_ad_limit_not_reached()
if self.config.publishing.delete_old_ads == "BEFORE_PUBLISH" and not self.keep_old_ads:
await self.delete_ad(ad_cfg, published_ads, delete_old_ads_by_title = self.config.publishing.delete_old_ads_by_title)
@@ -811,6 +810,20 @@ class KleinanzeigenBot(WebScrapingMixin):
except TimeoutError:
pass # nosec
#############################
# wait for payment form if commercial account is used
#############################
try:
await self.web_find(By.ID, "myftr-shppngcrt-frm", timeout = 2)
LOG.warning("############################################")
LOG.warning("# Payment form detected! Please proceed with payment.")
LOG.warning("############################################")
await self.web_scroll_page_down()
input(_("Press a key to continue..."))
except TimeoutError:
pass
await self.web_await(lambda: "p-anzeige-aufgeben-bestaetigung.html?adId=" in self.page.url, timeout = 20)
# extract the ad id from the URL's query parameter
@@ -1033,13 +1046,6 @@ class KleinanzeigenBot(WebScrapingMixin):
await image_upload.send_file(image)
await self.web_sleep()
async def assert_free_ad_limit_not_reached(self) -> None:
try:
await self.web_find(By.XPATH, "/html/body/div[1]/form/fieldset[6]/div[1]/header", timeout = 2)
raise AssertionError(f"Cannot publish more ads. The monthly limit of free ads of account {self.config.login.username} is reached.")
except TimeoutError:
pass
async def download_ads(self) -> None:
"""
Determines which download mode was chosen with the arguments, and calls the specified download routine.