cosmetic cleanup

This commit is contained in:
smilerz 2021-03-23 12:32:55 -05:00
parent cb708e7e47
commit 1188ed9227
2 changed files with 5 additions and 4 deletions

View File

@ -88,7 +88,6 @@ def get_recipe_from_source(text, url, space):
if 'url' in parse_list[0]:
url = parse_list[0]['url']
# first try finding ld+json as its most common
for el in parse_list:
@ -136,7 +135,7 @@ def get_from_html(soup):
html.append(s)
return html
# todo - look for site info in the soup
def get_images_from_source(soup, url):
sources = ['src', 'srcset', 'data-src']
images = []
@ -165,6 +164,7 @@ def get_images_from_source(soup, url):
images.append(u)
return images
def remove_graph(el):
# recipes type might be wrapped in @graph type
if isinstance(el, Tag):
@ -176,4 +176,4 @@ def remove_graph(el):
for x in el['@graph']:
if '@type' in x and x['@type'] == 'Recipe':
el = x
return el
return el

View File

@ -92,7 +92,7 @@ def find_recipe_json(ld_json, url, space):
ld_json['image'] = ""
if 'description' in ld_json:
ld_json['description'] = normalize_string(ld_json['description'] )
ld_json['description'] = normalize_string(ld_json['description'])
else:
ld_json['description'] = ""
@ -350,6 +350,7 @@ def parse_servings(servings):
servings = 1
return servings
def parse_cooktime(cooktime):
if type(cooktime) not in [int, float]:
try: