-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for SamsungFood (#1475)
- Loading branch information
Showing
6 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from ._abstract import AbstractScraper | ||
import re | ||
|
||
|
||
class SamsungFood(AbstractScraper): | ||
@classmethod | ||
def host(cls): | ||
return "app.samsungfood.com" | ||
|
||
def ingredients(self): | ||
schema_ingredients = self.schema.ingredients() | ||
return [ingredient.lstrip("- ").strip() for ingredient in schema_ingredients] | ||
|
||
def instructions(self): | ||
schema_instructions = self.schema.instructions() | ||
cleaned_instructions = [ | ||
re.sub(r"^\d+\.\s*", "", line).strip() | ||
for line in schema_instructions.split("\n") | ||
] | ||
return "\n".join(cleaned_instructions) | ||
|
||
def nutrients(self): | ||
schema_nutrients = self.schema.nutrients() | ||
|
||
if not schema_nutrients or not isinstance(schema_nutrients, dict): | ||
raise ValueError("Unexpected or missing nutrients data from schema.") | ||
|
||
parsed_nutrients = {} | ||
for nutrient, value in schema_nutrients.items(): | ||
if "calories" in nutrient.lower(): | ||
match = re.search(r"\d+(\.\d+)?", str(value)) | ||
if match: | ||
parsed_nutrients["calories"] = match.group(0) | ||
else: | ||
parsed_nutrients[nutrient] = str(value).strip('"') | ||
|
||
return parsed_nutrients |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"author": "STEPH De Sousa", | ||
"canonical_url": "https://app.samsungfood.com/recipes/107018a3052180271afa5138d3ead5f8c57", | ||
"site_name": "Samsung Food", | ||
"host": "app.samsungfood.com", | ||
"language": "en", | ||
"title": "5 Minute lemon and blueberry cake", | ||
"ingredients": [ | ||
"Zest from 2 fresh lemons", | ||
"1 cup sugar", | ||
"Juice from 1 tantalizing lemon", | ||
"2 fluffy eggs", | ||
"1/2 cup velvety olive oil", | ||
"1/2 cup creamy yoghurt", | ||
"1.5 cups self raising flour (magic in a cup!)", | ||
"1.5 cup frozen blueberries (nature’s candy)", | ||
"1 tbsp raw sugar for that extra sparkle ✨" | ||
], | ||
"instructions_list": [ | ||
"In your trusty bowl, combine sugar, lemon zest, lemon juice, eggs, oil, and yogurt. Give it a good mix! 💪", | ||
"Add in 1 cup of those yummy frozen blueberries and the self-raising flour. Stir it up!", | ||
"Pour that beautiful batter into a lined loaf tin.", | ||
"Decorate the top with the remaining blueberries and give it a sprinkle of raw sugar.", | ||
"Pop it in the oven at 160C and bake for a golden 50 minutes.", | ||
"Voilà! A blueberry-lemon dream ready in no time. Perfect for last-minute parties or a cheeky weekend snack. Enjoy, and don't forget to share your masterpiece with me! 🎂📸" | ||
], | ||
"category": "Desserts", | ||
"yields": "10 servings", | ||
"description": "Hey there, baking friends! 🍰 Frozen fruit is my go to when it comes to baking! It’s always ready to use, available, budget friendly, and doesn’t go rotten when I forget to use it🤣🤦♀️🍓 Are you ready for a quick treat that'll dazzle your tastebuds and impress anyone who gets a bite?", | ||
"total_time": 55, | ||
"cook_time": 50, | ||
"prep_time": 5, | ||
"cuisine": "World Cuisine", | ||
"ratings": 5.0, | ||
"ratings_count": 2, | ||
"nutrients": { | ||
"servingSize": "10", | ||
"calories": "2810.37", | ||
"fatContent": "129.8 g", | ||
"saturatedFatContent": "21.49 g", | ||
"transFatContent": "0.04 g", | ||
"carbohydrateContent": "389.06 g", | ||
"sugarContent": "237.75 g", | ||
"proteinContent": "35.13 g", | ||
"fiberContent": "12.74 g", | ||
"cholesterolContent": "343.29 mg" | ||
}, | ||
"image": "https://art.whisk.com/image/upload/fl_progressive,h_600,w_800,c_fill/v1693027610/v3/user-recipes/ab85a2475db2153dcbe548fd5dfc6577.jpg", | ||
"keywords": [ | ||
"5 Minute lemon and blueberry cake", | ||
"Desserts", | ||
"World Cuisine" | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"author": "Jackie Z goes low carb & low sodium", | ||
"canonical_url": "https://app.samsungfood.com/recipes/107c68e61bfac05481dadbeffc49aceba32", | ||
"site_name": "Samsung Food", | ||
"host": "app.samsungfood.com", | ||
"language": "en", | ||
"title": "Salmon poke bowl low carb low sodium", | ||
"ingredients": [ | ||
"120 g fresh salmon (skin and bones removed)", | ||
"1/2 cucumber", | ||
"1/2 punnet cherry tomatoes", | ||
"1/2 red onion", | ||
"Handful coriander", | ||
"Black sesame seeds", | ||
"1 tbs lime juice", | ||
"1 tsp low salt Tamari", | ||
"1/2 red chilli (optional)" | ||
], | ||
"instructions_list": [ | ||
"Set a frying pan on high heat and add the black sesame seeds. Toss and keep stirring until they are lightly toasted. You’ll be able to tell from the aroma. Set aside.", | ||
"Cut the red onions into thin slices. Half the cherry tomatoes. Cut the cucumber into thick slices, then quarter the slices. Roughly chop the coriander. If using, thinly slice the red chilli.", | ||
"Cut the fresh salmon into roughly one inch chunks.", | ||
"In a bowl, mix the lemon juice and low salt tamari sauce.", | ||
"Add the salmon and vegetables, and mix well.", | ||
"Sprinkle on the black sesame seeds." | ||
], | ||
"category": "Lunch", | ||
"yields": "1 serving", | ||
"description": "Delicious, fresh and healthy. Salmon is a great source of protein with many vital nutrients. Perfect for this low carb and low sodium poke bowl. For more recipes, join the community by clicking the source.", | ||
"total_time": 15, | ||
"prep_time": 15, | ||
"cuisine": "American", | ||
"ratings": 5.0, | ||
"ratings_count": 40, | ||
"nutrients": { | ||
"servingSize": "1", | ||
"calories": "296.27", | ||
"fatContent": "15.96 g", | ||
"saturatedFatContent": "2.53 g", | ||
"carbohydrateContent": "12.18 g", | ||
"sugarContent": "6.04 g", | ||
"proteinContent": "27.48 g", | ||
"fiberContent": "2.76 g", | ||
"cholesterolContent": "74.08 mg" | ||
}, | ||
"image": "https://art.whisk.com/image/upload/fl_progressive,h_600,w_800,c_fill/v1601773914/recipe/79db89a60b1df448ca57c67291a96782.jpg", | ||
"keywords": [ | ||
"Salmon poke bowl low carb low sodium", | ||
"Lunch", | ||
"American" | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.