mucahitkantepe commited on
Commit
3d2c012
·
1 Parent(s): c657278

massimodutti: drop products with no image URL at scrape time

Browse files
Files changed (1) hide show
  1. taste/scrapers/api/massimodutti.py +10 -2
taste/scrapers/api/massimodutti.py CHANGED
@@ -199,14 +199,22 @@ def _is_in_stock(product: dict[str, Any]) -> bool:
199
 
200
 
201
  def _to_standard(product: dict[str, Any], category_slug: str) -> dict[str, Any] | None:
202
- """Map Inditex schema to the taste-engine product dict shape."""
 
 
 
 
 
 
203
  pid = product.get("id")
204
  slug = product.get("productUrl")
205
  if not pid or not slug:
206
  return None
 
 
 
207
  url = f"https://www.massimodutti.com/no/en/{slug}.html?pelement={pid}"
208
  name = product.get("nameEn") or product.get("name") or ""
209
- images = _extract_image_urls(product)
210
  price, old_price, on_sale = _extract_price_nok(product)
211
  color = ""
212
  bcolors = product.get("bundleColors") or []
 
199
 
200
 
201
  def _to_standard(product: dict[str, Any], category_slug: str) -> dict[str, Any] | None:
202
+ """Map Inditex schema to the taste-engine product dict shape.
203
+
204
+ Returns None for products without any image URL — those rows can't be
205
+ scored or rendered, so we drop them at scrape time rather than polluting
206
+ the DB. Common causes: 'back soon' lifecycle, recently-added SKUs whose
207
+ media hasn't been published yet, or color variants with no xmedia.
208
+ """
209
  pid = product.get("id")
210
  slug = product.get("productUrl")
211
  if not pid or not slug:
212
  return None
213
+ images = _extract_image_urls(product)
214
+ if not images:
215
+ return None
216
  url = f"https://www.massimodutti.com/no/en/{slug}.html?pelement={pid}"
217
  name = product.get("nameEn") or product.get("name") or ""
 
218
  price, old_price, on_sale = _extract_price_nok(product)
219
  color = ""
220
  bcolors = product.get("bundleColors") or []