mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
Fixes #196
This commit is contained in:
parent
6fa1c3a4d9
commit
73b310a333
2 changed files with 15 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
import html
|
import html
|
||||||
import re
|
import re
|
||||||
|
from datetime import datetime
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from slugify import slugify
|
from slugify import slugify
|
||||||
|
@ -24,10 +25,13 @@ class Cleaner:
|
||||||
Returns:
|
Returns:
|
||||||
dict: cleaned recipe dictionary
|
dict: cleaned recipe dictionary
|
||||||
"""
|
"""
|
||||||
recipe_data["totalTime"] = Cleaner.time(recipe_data.get("totalTime"))
|
|
||||||
recipe_data["description"] = Cleaner.html(recipe_data.get("description", ""))
|
recipe_data["description"] = Cleaner.html(recipe_data.get("description", ""))
|
||||||
recipe_data["prepTime"] = Cleaner.time(recipe_data.get("prepTime"))
|
|
||||||
recipe_data["performTime"] = Cleaner.time(recipe_data.get("performTime"))
|
# Times
|
||||||
|
recipe_data["prepTime"] = Cleaner.time(recipe_data.get("prepTime", None))
|
||||||
|
recipe_data["performTime"] = Cleaner.time(recipe_data.get("performTime", None))
|
||||||
|
recipe_data["totalTime"] = Cleaner.time(recipe_data.get("totalTime", None))
|
||||||
|
|
||||||
recipe_data["recipeYield"] = Cleaner.yield_amount(
|
recipe_data["recipeYield"] = Cleaner.yield_amount(
|
||||||
recipe_data.get("recipeYield")
|
recipe_data.get("recipeYield")
|
||||||
)
|
)
|
||||||
|
@ -144,8 +148,13 @@ class Cleaner:
|
||||||
return yld
|
return yld
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def time(time_entry) -> str:
|
def time(time_entry):
|
||||||
if type(time_entry) == type(None):
|
print(time_entry, type(time_entry))
|
||||||
|
if time_entry == None:
|
||||||
return None
|
return None
|
||||||
|
elif type(time_entry) == datetime:
|
||||||
|
print(time_entry)
|
||||||
elif type(time_entry) != str:
|
elif type(time_entry) != str:
|
||||||
return str(time_entry)
|
return str(time_entry)
|
||||||
|
elif time_entry != None:
|
||||||
|
return time_entry
|
||||||
|
|
|
@ -25,6 +25,7 @@ def create_from_url(url: str) -> Recipe:
|
||||||
"""
|
"""
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
new_recipe = extract_recipe_from_html(r.text, url)
|
new_recipe = extract_recipe_from_html(r.text, url)
|
||||||
|
print(new_recipe)
|
||||||
new_recipe = Cleaner.clean(new_recipe, url)
|
new_recipe = Cleaner.clean(new_recipe, url)
|
||||||
new_recipe = download_image_for_recipe(new_recipe)
|
new_recipe = download_image_for_recipe(new_recipe)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue