Fixes broken --ads parameter (#249)

This commit is contained in:
Heavenfighter
2024-01-05 20:19:20 +01:00
committed by GitHub
parent c66b4a3eb8
commit 078149bd2a

View File

@@ -238,8 +238,10 @@ class KleinanzeigenBot(SeleniumMixin):
descr_suffix = self.config["ad_defaults"]["description"]["suffix"] or ""
ids = []
use_specific_ads = False
if re.compile(r'\d+[,\d+]*').search(self.ads_selector):
ids = [int(n) for n in self.ads_selector.split(',')]
use_specific_ads = True
LOG.info('Start fetch task for the ad(s) with the id(s):')
LOG.info(' | '.join([str(id_) for id_ in ids]))
@@ -256,6 +258,11 @@ class KleinanzeigenBot(SeleniumMixin):
LOG.info(" -> SKIPPED: inactive ad [%s]", ad_file)
continue
if use_specific_ads:
if not ad_cfg["id"] in ids:
LOG.info(" -> SKIPPED: ad [%s] is not in list of given ids.", ad_file)
continue
else:
if self.ads_selector == "new" and ad_cfg["id"] and check_id:
LOG.info(" -> SKIPPED: ad [%s] is not new. already has an id assigned.", ad_file)
continue
@@ -278,10 +285,6 @@ class KleinanzeigenBot(SeleniumMixin):
)
continue
if not ad_cfg["id"] in ids:
LOG.info(" -> SKIPPED: ad [%s] is not in list of given ids.", ad_file)
continue
ad_cfg["description"] = descr_prefix + (ad_cfg["description"] or "") + descr_suffix
ensure(len(ad_cfg["description"]) <= 4000, f"Length of ad description including prefix and suffix exceeds 4000 chars. @ [{ad_file}]")