Add precision gear dimension images
This commit is contained in:
@@ -21,6 +21,7 @@ def main() -> None:
|
||||
args = parser.parse_args()
|
||||
|
||||
source = json.loads(args.source.read_text(encoding="utf-8"))
|
||||
images_root = args.source.parent.parent / "images"
|
||||
items = [item for item in source.values() if item.get("top_cat") == "精密齿轮配件"]
|
||||
items.sort(key=lambda item: (item.get("sub_cat", ""), int(item.get("id", 0))))
|
||||
|
||||
@@ -34,8 +35,7 @@ def main() -> None:
|
||||
for label, value in item.get("specs", {}).items()
|
||||
if str(value).strip()
|
||||
}
|
||||
products.append(
|
||||
{
|
||||
product = {
|
||||
"id": f"gear-{item['id']}",
|
||||
"category": "精密齿轮配件",
|
||||
"subCategory": subcategory,
|
||||
@@ -46,8 +46,16 @@ def main() -> None:
|
||||
"specs": specs,
|
||||
"torqueValue": None,
|
||||
"ratedVoltage": None,
|
||||
}
|
||||
)
|
||||
}
|
||||
folders = sorted(images_root.glob(f"{item['id']}_*"))
|
||||
dimension_files = []
|
||||
if folders:
|
||||
dimension_files = sorted(folders[0].glob("desc1.*"))
|
||||
if not dimension_files:
|
||||
dimension_files = sorted(folders[0].glob("slide2.*"))
|
||||
if dimension_files:
|
||||
product["dimensionImage"] = f"/catalog-products/precision-gears-size/{item['id']}.jpg"
|
||||
products.append(product)
|
||||
|
||||
output = [
|
||||
"// Generated from 商城产品资料_20260806/data/parsed_products.json.",
|
||||
|
||||
Reference in New Issue
Block a user