Compare commits

..

2 Commits

Author SHA1 Message Date
Ching
8e17ee3932 Merge branch 'main' of https://git.tunpok.com/ching/grocy-barcode-helper into main
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-08 16:28:42 +08:00
Ching
fc5dd132ce fix(recipe): Refactor get_recipe_from_xiachufang to handle steps without images 2024-03-08 16:28:37 +08:00
2 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,6 @@
{
"conventionalCommits.scopes": [
"api"
"api",
"recipe"
]
}

View File

@ -15,6 +15,11 @@ def get_recipe_from_xiachufang(url):
steps = []
for step in soup.find('div', class_='steps').find('ol').find_all('li'):
steps.append([step.find('p').text.strip(), step.find('img')['src']])
step_text = step.find('p').text.strip()
step_img = step.find('img')
if step_img:
steps.append([step_text, step_img['src']])
else:
steps.append([step_text])
return {'name': name, 'ingredients': ingredients, 'steps': steps}