Spaces:
Running on Zero
Running on Zero
Muneesh commited on
Commit ·
e5c56ea
1
Parent(s): ac148ce
fix(bigbasket): more defensive pricing parsing
Browse files- providers/bigbasket.py +13 -7
providers/bigbasket.py
CHANGED
|
@@ -67,15 +67,21 @@ class BigBasketProvider(BaseProvider):
|
|
| 67 |
continue
|
| 68 |
|
| 69 |
# Pricing: pricing.discount.mrp (string), pricing.discount.prim_price.sp (string)
|
| 70 |
-
pricing = item.get("pricing"
|
| 71 |
-
discount_info = pricing.get("discount"
|
| 72 |
-
|
| 73 |
-
prim_price = discount_info.get("prim_price"
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
try:
|
| 77 |
-
price = float(
|
| 78 |
-
mrp = float(
|
| 79 |
except (ValueError, TypeError):
|
| 80 |
continue
|
| 81 |
if price <= 0:
|
|
|
|
| 67 |
continue
|
| 68 |
|
| 69 |
# Pricing: pricing.discount.mrp (string), pricing.discount.prim_price.sp (string)
|
| 70 |
+
pricing = item.get("pricing") or {}
|
| 71 |
+
discount_info = pricing.get("discount") or {}
|
| 72 |
+
mrp_raw = discount_info.get("mrp", "0")
|
| 73 |
+
prim_price = discount_info.get("prim_price") or {}
|
| 74 |
+
sp_raw = prim_price.get("sp") or mrp_raw
|
| 75 |
+
|
| 76 |
+
# Also try top-level pricing keys as fallback
|
| 77 |
+
if not sp_raw or str(sp_raw) == "0":
|
| 78 |
+
sp_raw = pricing.get("sp") or pricing.get("price") or pricing.get("selling_price") or "0"
|
| 79 |
+
if not mrp_raw or str(mrp_raw) == "0":
|
| 80 |
+
mrp_raw = pricing.get("mrp") or pricing.get("mrp_price") or sp_raw
|
| 81 |
|
| 82 |
try:
|
| 83 |
+
price = float(str(sp_raw).replace(",", "").strip())
|
| 84 |
+
mrp = float(str(mrp_raw).replace(",", "").strip())
|
| 85 |
except (ValueError, TypeError):
|
| 86 |
continue
|
| 87 |
if price <= 0:
|