diff --git a/recipe_scrapers/__init__.py b/recipe_scrapers/__init__.py index 5f784cccb..fc74a2dc0 100644 --- a/recipe_scrapers/__init__.py +++ b/recipe_scrapers/__init__.py @@ -354,6 +354,7 @@ from .sallysbakingaddiction import SallysBakingAddiction from .sallysblog import SallysBlog from .saltpepperskillet import SaltPepperSkillet +from .samsungfood import SamsungFood from .sandwhichtribunal import SandwhichTribunal from .saveur import Saveur from .savorynothings import SavoryNothings @@ -630,6 +631,7 @@ Rewe.host(): Rewe, RecipeLand.host(): RecipeLand, RicettePerBimby.host(): RicettePerBimby, + SamsungFood.host(): SamsungFood, SandwhichTribunal.host(): SandwhichTribunal, SavoryNothings.host(): SavoryNothings, SheLikesFood.host(): SheLikesFood, diff --git a/recipe_scrapers/samsungfood.py b/recipe_scrapers/samsungfood.py new file mode 100644 index 000000000..1aeb8d74b --- /dev/null +++ b/recipe_scrapers/samsungfood.py @@ -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 diff --git a/tests/test_data/app.samsungfood.com/samsungfood_1.json b/tests/test_data/app.samsungfood.com/samsungfood_1.json new file mode 100644 index 000000000..986c1e85c --- /dev/null +++ b/tests/test_data/app.samsungfood.com/samsungfood_1.json @@ -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" + ] +} diff --git a/tests/test_data/app.samsungfood.com/samsungfood_1.testhtml b/tests/test_data/app.samsungfood.com/samsungfood_1.testhtml new file mode 100644 index 000000000..3c205c2ec --- /dev/null +++ b/tests/test_data/app.samsungfood.com/samsungfood_1.testhtml @@ -0,0 +1,7 @@ +5 Minute lemon and blueberry cake Recipe | Samsung Food App
Samsung Food
Log in
Use App
Log in
STEPH De Sousa
By STEPH De Sousa

5 Minute lemon and blueberry cake

6 steps
Prep:5minCook:50min
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? +
Updated at: Sat, 26 Aug 2023 05:30:01 GMT

Nutrition balance score

Unbalanced
Glycemic Index
67
Moderate
Glycemic Load
26
High

Nutrition per serving

Calories281 kcal (14%)
Total Fat13 g (19%)
Carbs38.9 g (15%)
Sugars23.8 g (26%)
Protein3.5 g (7%)
Sodium242.2 mg (12%)
Fiber1.3 g (5%)
% Daily Values based on a 2,000 calorie diet

Instructions

Step 1
1. In your trusty bowl, combine sugar, lemon zest, lemon juice, eggs, oil, and yogurt. Give it a good mix! 💪
Step 2
2. Add in 1 cup of those yummy frozen blueberries and the self-raising flour. Stir it up!
Step 3
3. Pour that beautiful batter into a lined loaf tin.
Step 4
4. Decorate the top with the remaining blueberries and give it a sprinkle of raw sugar.
Step 5
5. Pop it in the oven at 160C and bake for a golden 50 minutes.
Step 6
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! 🎂📸

Notes

2 liked
0 disliked
Special occasion
There are no notes yet. Be the first to share your experience!
\ No newline at end of file diff --git a/tests/test_data/app.samsungfood.com/samsungfood_2.json b/tests/test_data/app.samsungfood.com/samsungfood_2.json new file mode 100644 index 000000000..52432388b --- /dev/null +++ b/tests/test_data/app.samsungfood.com/samsungfood_2.json @@ -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" + ] +} diff --git a/tests/test_data/app.samsungfood.com/samsungfood_2.testhtml b/tests/test_data/app.samsungfood.com/samsungfood_2.testhtml new file mode 100644 index 000000000..e206d539b --- /dev/null +++ b/tests/test_data/app.samsungfood.com/samsungfood_2.testhtml @@ -0,0 +1,9 @@ +Salmon poke bowl low carb low sodium Recipe | Samsung Food App
Samsung Food
Log in
Use App
Log in
Jackie Ziegler
By Jackie Ziegler

Salmon poke bowl low carb low sodium

6 steps
Prep:15min
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.
Updated at: Thu, 17 Aug 2023 12:07:50 GMT

Nutrition balance score

Great
Glycemic Index
23
Low
Glycemic Load
3
Low

Nutrition per serving

Calories296.3 kcal (15%)
Total Fat16 g (23%)
Carbs12.2 g (5%)
Sugars6 g (7%)
Protein27.5 g (55%)
Sodium232.3 mg (12%)
Fiber2.8 g (10%)
% Daily Values based on a 2,000 calorie diet

Instructions

Step 1
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.
Frying PanFrying Pan
black sesame seedsblack sesame seeds
Step 2
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.
KnifeKnife
red onionred onion0.5
cherry tomatoescherry tomatoes0.5 punnet
cucumbercucumber0.5
coriandercoriander
red chillired chilli0.5
Step 3
Cut the fresh salmon into roughly one inch chunks.
KnifeKnife
fresh salmonfresh salmon120g
Step 4
In a bowl, mix the lemon juice and low salt tamari sauce.
BowlBowl
lime juicelime juice1 Tbs
low salt tamarilow salt tamari1 tsp
Step 5
Add the salmon and vegetables, and mix well.
Step 6
Sprinkle on the black sesame seeds.
View on Jackie Z goes low carb & low sodium
Support creators by visiting their site 😊
\ No newline at end of file