paprika importer improvements

This commit is contained in:
vabene1111
2022-04-04 21:30:00 +02:00
parent 85aad42529
commit 090e18e405
2 changed files with 15 additions and 6 deletions

View File

@ -31,7 +31,7 @@ def get_from_scraper(scrape, request):
recipe_json['name'] = ''
try:
description = scrape.description() or None
description = scrape.description() or None
except Exception:
description = None
if not description:
@ -130,7 +130,7 @@ def get_from_scraper(scrape, request):
if len(recipe_json['steps']) == 0:
recipe_json['steps'].append({'instruction': '', 'ingredients': [], })
if len(parse_description(description)) > 256: # split at 256 as long descriptions dont look good on recipe cards
if len(parse_description(description)) > 256: # split at 256 as long descriptions dont look good on recipe cards
recipe_json['steps'][0]['instruction'] = f'*{parse_description(description)}* \n\n' + recipe_json['steps'][0]['instruction']
else:
recipe_json['description'] = parse_description(description)[:512]
@ -255,6 +255,15 @@ def parse_servings(servings):
return servings
def parse_servings_text(servings):
if type(servings) == str:
try:
servings = re.sub("\d+", '', servings).strip()
except Exception:
servings = ''
return servings
def parse_time(recipe_time):
if type(recipe_time) not in [int, float]:
try: