Skip to content

Commit 7a3c5fc

Browse files
fix: handle missing .versand_s for service categories like … (#579)
There are categories which are not require shipping and there is no shipping field ## ℹ️ Description For example category 297/298 does not require shipping, because its a service category. The current code did not handle that case and was searching for a path with .versand_s, but in this category, there is no such path. ## 📋 Changes Summary If the shipping_type is set to NOT_APPLICABLE in the configuration, the shipping assignment step is skipped instead of being forced. ### ⚙️ Type of Change Select the type(s) of change(s) included in this pull request: - [x] 🐞 Bug fix (non-breaking change which fixes an issue) - [ ] ✨ New feature (adds new functionality without breaking existing usage) - [ ] 💥 Breaking change (changes that might break existing user setups, scripts, or configurations) ## ✅ Checklist Before requesting a review, confirm the following: - [x] I have reviewed my changes to ensure they meet the project's standards. - [x] I have tested my changes and ensured that all tests pass (`pdm run test`). - [x] I have formatted the code (`pdm run format`). - [x] I have verified that linting passes (`pdm run lint`). - [x] I have updated documentation where necessary. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 280a72c commit 7a3c5fc

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/kleinanzeigen_bot/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -766,16 +766,20 @@ async def publish_ad(self, ad_file:str, ad_cfg:Ad, ad_cfg_orig:dict[str, Any], p
766766
#############################
767767
# set shipping type/options/costs
768768
#############################
769-
if ad_cfg.type == "WANTED":
770-
# special handling for ads of type WANTED since shipping is a special attribute for these
771-
if ad_cfg.shipping_type in {"PICKUP", "SHIPPING"}:
772-
shipping_value = "ja" if ad_cfg.shipping_type == "SHIPPING" else "nein"
773-
try:
774-
await self.web_select(By.XPATH, "//select[contains(@id, '.versand_s')]", shipping_value)
775-
except TimeoutError:
776-
LOG.warning("Failed to set shipping attribute for type '%s'!", ad_cfg.shipping_type)
769+
shipping_type = ad_cfg.shipping_type
770+
if shipping_type != "NOT_APPLICABLE":
771+
if ad_cfg.type == "WANTED":
772+
# special handling for ads of type WANTED since shipping is a special attribute for these
773+
if shipping_type in {"PICKUP", "SHIPPING"}:
774+
shipping_value = "ja" if shipping_type == "SHIPPING" else "nein"
775+
try:
776+
await self.web_select(By.XPATH, "//select[contains(@id, '.versand_s')]", shipping_value)
777+
except TimeoutError:
778+
LOG.warning("Failed to set shipping attribute for type '%s'!", shipping_type)
779+
else:
780+
await self.__set_shipping(ad_cfg, mode)
777781
else:
778-
await self.__set_shipping(ad_cfg, mode)
782+
LOG.debug("Shipping step skipped - reason: NOT_APPLICABLE")
779783

780784
#############################
781785
# set price

src/kleinanzeigen_bot/resources/translations.de.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ kleinanzeigen_bot/__init__.py:
8989
"Publishing ad '%s'...": "Veröffentliche Anzeige '%s'..."
9090
"Updating ad '%s'...": "Aktualisiere Anzeige '%s'..."
9191
"Failed to set shipping attribute for type '%s'!": "Fehler beim setzen des Versandattributs für den Typ '%s'!"
92+
"Shipping step skipped - reason: NOT_APPLICABLE": "Versandschritt übersprungen: Versand nicht anwendbar (Status = NOT_APPLICABLE)"
9293
"# Payment form detected! Please proceed with payment.": "# Bestellformular gefunden! Bitte mit der Bezahlung fortfahren."
9394
" -> SUCCESS: ad published with ID %s": " -> ERFOLG: Anzeige mit ID %s veröffentlicht"
9495
" -> SUCCESS: ad updated with ID %s": " -> ERFOLG: Anzeige mit ID %s aktualisiert"

0 commit comments

Comments
 (0)