Commit
·
fefecb6
1
Parent(s):
1b944da
Fix a parsing bug
Browse files
app.py
CHANGED
@@ -64,7 +64,11 @@ def get_additional_images(id_product_money: str, marketplace: str) -> List[str]:
|
|
64 |
result = connection.execute(query, {"id_product_money": id_product_money}).first()
|
65 |
if result and result.more_images:
|
66 |
print(f"Lamoda raw more_images: {result.more_images}")
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
return [f"https://a.lmcdn.ru/product{path}" for path in paths]
|
69 |
|
70 |
elif marketplace == 'wildberries':
|
@@ -137,8 +141,13 @@ def process_input(id_product_money: str, prompt: str) -> Tuple[List[str], str, s
|
|
137 |
additional_images = get_additional_images(id_product_money, marketplace)
|
138 |
print(f"Additional images: {additional_images}")
|
139 |
|
140 |
-
# Combine all images
|
141 |
-
all_image_urls = [
|
|
|
|
|
|
|
|
|
|
|
142 |
print(f"\nAll image URLs: {all_image_urls}")
|
143 |
|
144 |
print("\nDownloading and encoding images...")
|
|
|
64 |
result = connection.execute(query, {"id_product_money": id_product_money}).first()
|
65 |
if result and result.more_images:
|
66 |
print(f"Lamoda raw more_images: {result.more_images}")
|
67 |
+
# Handle both string JSON and direct list cases
|
68 |
+
if isinstance(result.more_images, str):
|
69 |
+
paths = json.loads(result.more_images)
|
70 |
+
else:
|
71 |
+
paths = result.more_images
|
72 |
return [f"https://a.lmcdn.ru/product{path}" for path in paths]
|
73 |
|
74 |
elif marketplace == 'wildberries':
|
|
|
141 |
additional_images = get_additional_images(id_product_money, marketplace)
|
142 |
print(f"Additional images: {additional_images}")
|
143 |
|
144 |
+
# Combine all images and remove duplicates while preserving order
|
145 |
+
all_image_urls = []
|
146 |
+
seen = set()
|
147 |
+
for url in [main_image] + additional_images:
|
148 |
+
if url not in seen:
|
149 |
+
seen.add(url)
|
150 |
+
all_image_urls.append(url)
|
151 |
print(f"\nAll image URLs: {all_image_urls}")
|
152 |
|
153 |
print("\nDownloading and encoding images...")
|