mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
feat: if a category is not found try to lookup fallback category
This commit is contained in:
@@ -319,7 +319,18 @@ class KleinanzeigenBot(WebScrapingMixin):
|
|||||||
ad_cfg["id"] = int(ad_cfg["id"])
|
ad_cfg["id"] = int(ad_cfg["id"])
|
||||||
|
|
||||||
if ad_cfg["category"]:
|
if ad_cfg["category"]:
|
||||||
ad_cfg["category"] = self.categories.get(ad_cfg["category"], ad_cfg["category"])
|
resolved_category_id = self.categories.get(ad_cfg["category"])
|
||||||
|
if not resolved_category_id and ">" in ad_cfg["category"]:
|
||||||
|
# this maps actually to the sonstiges/weiteres sub-category
|
||||||
|
parent_category = ad_cfg["category"].rpartition(">")[0].strip()
|
||||||
|
resolved_category_id = self.categories.get(parent_category)
|
||||||
|
if resolved_category_id:
|
||||||
|
LOG.warning(
|
||||||
|
"Category [%s] unknown. Using category [%s] with ID [%s] instead.",
|
||||||
|
ad_cfg["category"], parent_category, resolved_category_id)
|
||||||
|
|
||||||
|
if resolved_category_id:
|
||||||
|
ad_cfg["category"] = resolved_category_id
|
||||||
|
|
||||||
if ad_cfg["shipping_costs"]:
|
if ad_cfg["shipping_costs"]:
|
||||||
ad_cfg["shipping_costs"] = str(round(utils.parse_decimal(ad_cfg["shipping_costs"]), 2))
|
ad_cfg["shipping_costs"] = str(round(utils.parse_decimal(ad_cfg["shipping_costs"]), 2))
|
||||||
|
|||||||
Reference in New Issue
Block a user