|
1 | | -import re |
2 | | -from datetime import UTC, datetime |
| 1 | +from datetime import datetime |
3 | 2 | from zoneinfo import ZoneInfo |
4 | 3 |
|
5 | 4 | import logfire |
|
9 | 8 | Image, |
10 | 9 | Link, |
11 | 10 | NikeLaunch, |
12 | | - Price, |
13 | 11 | Sneaker, |
14 | 12 | SneakerSize, |
15 | 13 | ) |
@@ -289,23 +287,22 @@ def json_to_sneakers(self, json: dict) -> list[Sneaker]: |
289 | 287 | # First, check for 1st-level cards that are images and see if any productIds match |
290 | 288 | position = 0 |
291 | 289 | for card in thread["cards"]: |
292 | | - if card["subType"] == "image": |
293 | | - if card.get("actions"): |
294 | | - # if any action has a productId that matches the current productId, use this image |
295 | | - for action in card["actions"]: |
296 | | - if action["product"]["productId"] == product_id: |
297 | | - if card.get("imageId") and card.get("imageSlug"): |
298 | | - image_url = f"https://static.nike.com/a/images/{card['imageId']}/{card['imageSlug']}.jpg" |
299 | | - else: |
300 | | - image_url = card["defaultURL"] |
301 | | - sneaker_images.append( |
302 | | - Image( |
303 | | - platform=Platform.RETAIL, |
304 | | - position=position, |
305 | | - url=image_url, |
306 | | - ), |
307 | | - ) |
308 | | - position += 1 |
| 290 | + if card["subType"] == "image" and card.get("actions"): |
| 291 | + # if any action has a productId that matches the current productId, use this image |
| 292 | + for action in card["actions"]: |
| 293 | + if action["product"]["productId"] == product_id: |
| 294 | + if card.get("imageId") and card.get("imageSlug"): |
| 295 | + image_url = f"https://static.nike.com/a/images/{card['imageId']}/{card['imageSlug']}.jpg" |
| 296 | + else: |
| 297 | + image_url = card["defaultURL"] |
| 298 | + sneaker_images.append( |
| 299 | + Image( |
| 300 | + platform=Platform.RETAIL, |
| 301 | + position=position, |
| 302 | + url=image_url, |
| 303 | + ), |
| 304 | + ) |
| 305 | + position += 1 |
309 | 306 | if not sneaker_images: |
310 | 307 | for index, image in enumerate(carousel["cards"]): |
311 | 308 | if image["subType"] == "image": |
|
0 commit comments