Spaces:
Sleeping
Sleeping
Update coupons.py
Browse files- coupons.py +11 -9
coupons.py
CHANGED
|
@@ -135,15 +135,17 @@ async def fetch_active_coupons_and_deals(product_name: str, client: httpx.AsyncC
|
|
| 135 |
desc_val = str(o.get('description', ''))
|
| 136 |
source_val = str(o.get('source', ''))
|
| 137 |
|
| 138 |
-
#
|
| 139 |
-
if
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
| 147 |
|
| 148 |
if desc_val:
|
| 149 |
clean_offers.append({
|
|
|
|
| 135 |
desc_val = str(o.get('description', ''))
|
| 136 |
source_val = str(o.get('source', ''))
|
| 137 |
|
| 138 |
+
# Normalize missing, broken, or placeholder codes to an empty string
|
| 139 |
+
if code_val in blacklisted_tokens or code_val == "N/A" or not code_val:
|
| 140 |
+
code_val = ""
|
| 141 |
+
|
| 142 |
+
# Dynamic re-classification safety check
|
| 143 |
+
if offer_type == "coupon" and not code_val:
|
| 144 |
+
offer_type = "deal"
|
| 145 |
+
|
| 146 |
+
# Clear out lazy clickbait affiliate phrases
|
| 147 |
+
if "click" in desc_val.lower() and len(desc_val) < 15:
|
| 148 |
+
continue
|
| 149 |
|
| 150 |
if desc_val:
|
| 151 |
clean_offers.append({
|