Merge pull request #1156 from TandoorRecipes/1129_patch

fixes 1129
This commit is contained in:
vabene1111 2021-12-23 14:59:45 +01:00 committed by GitHub
commit e2915dde55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,13 +1,14 @@
import json import json
import re import re
from json import JSONDecodeError
from urllib.parse import unquote
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from bs4.element import Tag from bs4.element import Tag
from recipe_scrapers._utils import get_host_name, normalize_string
from cookbook.helper import recipe_url_import as helper from cookbook.helper import recipe_url_import as helper
from cookbook.helper.scrapers.scrapers import text_scraper from cookbook.helper.scrapers.scrapers import text_scraper
from json import JSONDecodeError
from recipe_scrapers._utils import get_host_name, normalize_string
from urllib.parse import unquote
def get_recipe_from_source(text, url, request): def get_recipe_from_source(text, url, request):
@ -58,7 +59,7 @@ def get_recipe_from_source(text, url, request):
return kid_list return kid_list
recipe_json = { recipe_json = {
'name': '', 'name': '',
'url': '', 'url': '',
'description': '', 'description': '',
'image': '', 'image': '',
@ -188,6 +189,6 @@ def remove_graph(el):
for x in el['@graph']: for x in el['@graph']:
if '@type' in x and x['@type'] == 'Recipe': if '@type' in x and x['@type'] == 'Recipe':
el = x el = x
except TypeError: except (TypeError, JSONDecodeError):
pass pass
return el return el