mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
fix: Make OpenAI Image Scraping More Fault Tolerant (#3749)
This commit is contained in:
parent
20b1b3de35
commit
22fc29742a
@ -257,7 +257,10 @@ class RecipeScraperOpenAI(RecipeScraperPackage):
|
|||||||
if not width or not height:
|
if not width or not height:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
size = int(width) * int(height)
|
try:
|
||||||
|
size = int(width) * int(height)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
size = 1
|
||||||
if size > max_size:
|
if size > max_size:
|
||||||
max_size = size
|
max_size = size
|
||||||
largest_img = img
|
largest_img = img
|
||||||
@ -273,7 +276,10 @@ class RecipeScraperOpenAI(RecipeScraperPackage):
|
|||||||
text = soup.get_text(separator="\n", strip=True)
|
text = soup.get_text(separator="\n", strip=True)
|
||||||
if not text:
|
if not text:
|
||||||
raise Exception("No text found in HTML")
|
raise Exception("No text found in HTML")
|
||||||
image = self.find_image(soup)
|
try:
|
||||||
|
image = self.find_image(soup)
|
||||||
|
except Exception:
|
||||||
|
image = None
|
||||||
|
|
||||||
components = [f"Convert this content to JSON: {text}"]
|
components = [f"Convert this content to JSON: {text}"]
|
||||||
if image:
|
if image:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user