55tee = "├── "
66last = "└── "
77
8+ IMAGE_SIZES = ["small" , "medium" , "regualr" , "large" , "extra-large" ]
9+ IMAGE_BASE_URL = "https://storefront-prod.nl.picnicinternational.com/static/images"
810
911def _tree_generator (response : list , prefix : str = "" ):
1012 """A recursive tree generator,
@@ -23,3 +25,19 @@ def _tree_generator(response: list, prefix: str = ""):
2325
2426def _url_generator (url : str , country_code : str , api_version : str ):
2527 return url .format (country_code .lower (), api_version )
28+
29+
30+ def get_recipe_image (id : str , size = "regular" ):
31+ sizes = IMAGE_SIZES + ["1250x1250" ]
32+ assert size in sizes , "size must be one of: " + ", " .join (sizes )
33+ return f"{ IMAGE_BASE_URL } /recipes/{ id } /{ size } .png"
34+
35+
36+ def get_image (id : str , size = "regular" , suffix = "webp" ):
37+ assert suffix in ["webp" , "png" ], "suffix must be webp or png"
38+ sizes = IMAGE_SIZES + [f"tile-{ size } " for size in IMAGE_SIZES ]
39+
40+ assert size in sizes , (
41+ "size must be one of: " + ", " .join (sizes )
42+ )
43+ return f"{ IMAGE_BASE_URL } /{ id } /{ size } .{ suffix } "
0 commit comments