From dd07c56ede89c971b3dfc5b4f8548783c5c7c703 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 15 Dec 2020 21:52:56 +0100 Subject: [PATCH] fixed issue with new fraction importer --- cookbook/helper/recipe_url_import.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index 8793a5f3e..bbba81c1e 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -79,10 +79,11 @@ def find_recipe_json(ld_json, url): ingredient = " ".join(ingredient_split[2:]) unit = ingredient_split[1] - if 'fraction' in unicodedata.decomposition(ingredient_split[0]): - frac_split = unicodedata.decomposition(ingredient_split[0]).split() - amount = round(float((frac_split[1]).replace('003', '')) / float((frac_split[3]).replace('003', '')), 3) - else: + try: + if 'fraction' in unicodedata.decomposition(ingredient_split[0]): + frac_split = unicodedata.decomposition(ingredient_split[0]).split() + amount = round(float((frac_split[1]).replace('003', '')) / float((frac_split[3]).replace('003', '')), 3) + except TypeError: # raised by unicodedata.decomposition if there was no unicode character in parsed data try: amount = float(ingredient_split[0].replace(',', '.')) except ValueError: