mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
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:
@@ -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.
|
||||
|
||||
@@ -112,6 +112,7 @@ class AdExtractor(WebScrapingMixin):
|
||||
:param url: the URL to the ad page
|
||||
:return: the ad ID, a (ten-digit) integer number
|
||||
"""
|
||||
|
||||
num_part = url.rsplit("/", maxsplit = 1)[-1] # suffix
|
||||
id_part = num_part.split("-", maxsplit = 1)[0]
|
||||
|
||||
|
||||
@@ -87,9 +87,11 @@ kleinanzeigen_bot/__init__.py:
|
||||
publish_ad:
|
||||
"Publishing ad '%s'...": "Veröffentliche Anzeige '%s'..."
|
||||
"Failed to set shipping attribute for type '%s'!": "Fehler beim setzen des Versandattributs für den Typ '%s'!"
|
||||
"# Payment form detected! Please proceed with payment.": "# Bestellformular gefunden! Bitte mit der Bezahlung fortfahren."
|
||||
" -> SUCCESS: ad published with ID %s": " -> ERFOLG: Anzeige mit ID %s veröffentlicht"
|
||||
" -> effective ad meta:": " -> effektive Anzeigen-Metadaten:"
|
||||
"Could not set city from location": "Stadt konnte nicht aus dem Standort gesetzt werden"
|
||||
"Press a key to continue...": "Eine Taste drücken, um fortzufahren..."
|
||||
|
||||
__set_condition:
|
||||
"Unable to close condition dialog!": "Kann den Dialog für Artikelzustand nicht schließen!"
|
||||
|
||||
Reference in New Issue
Block a user