fix: handle delayed ad publication #414 (#422)

This commit is contained in:
Heavenfighter
2025-02-11 20:43:33 +01:00
committed by GitHub
parent 820ae8966e
commit a67112d936

View File

@@ -775,9 +775,12 @@ class KleinanzeigenBot(WebScrapingMixin):
await self.web_click(By.ID, "imprint-guidance-submit")
# check for no image question
image_hint_xpath = '//*[contains(@class, "ModalDialog--Actions")]//button[.//*[text()[contains(.,"Ohne Bild veröffentlichen")]]]'
if not ad_cfg["images"] and await self.web_check(By.XPATH, image_hint_xpath, Is.DISPLAYED):
await self.web_click(By.XPATH, image_hint_xpath)
try:
image_hint_xpath = '//*[contains(@class, "ModalDialog--Actions")]//button[.//*[text()[contains(.,"Ohne Bild veröffentlichen")]]]'
if not ad_cfg["images"] and await self.web_check(By.XPATH, image_hint_xpath, Is.DISPLAYED):
await self.web_click(By.XPATH, image_hint_xpath)
except TimeoutError:
pass # nosec
await self.web_await(lambda: "p-anzeige-aufgeben-bestaetigung.html?adId=" in self.page.url, timeout = 20)
@@ -786,6 +789,14 @@ class KleinanzeigenBot(WebScrapingMixin):
ad_id = int(current_url_query_params.get("adId", [])[0])
ad_cfg_orig["id"] = ad_id
# check for approval message
try:
approval_link_xpath = '//*[contains(@id, "not-completed")]//*//a[contains(@class, "to-my-ads-link")]'
if await self.web_check(By.XPATH, approval_link_xpath, Is.DISPLAYED):
await self.web_click(By.XPATH, approval_link_xpath)
except TimeoutError:
pass # nosec
# Update content hash after successful publication
# Calculate hash on original config to ensure consistent comparison on restart
ad_cfg_orig["content_hash"] = calculate_content_hash(ad_cfg_orig)