From a2954554b5a572014ba41996ee3c115ed3cd91e4 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Mon, 4 Apr 2022 19:26:47 +0200 Subject: [PATCH] fixed description length limit --- cookbook/helper/recipe_url_import.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index 10e29a42c..d86e23aa0 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -40,7 +40,6 @@ def get_from_scraper(scrape, request): except Exception: description = '' - recipe_json['description'] = parse_description(description)[:512] recipe_json['internal'] = True try: @@ -131,6 +130,11 @@ 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 + recipe_json['steps'][0]['instruction'] = f'*{parse_description(description)}* \n\n' + recipe_json['steps'][0]['instruction'] + else: + recipe_json['description'] = parse_description(description)[:512] + try: for x in scrape.ingredients(): try: