From 7773b2785c06010e9b99f9ba1093768c279aad32 Mon Sep 17 00:00:00 2001 From: Kayos Date: Fri, 1 May 2026 07:40:41 -0700 Subject: [PATCH] =?UTF-8?q?discover:=20fix=20recipe-scrapers=2015.6=20API?= =?UTF-8?q?=20=E2=80=94=20drop=20wild=5Fmode=20kw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scrape_me(url) no longer accepts wild_mode in 15.x. Two-stage fallback: 1. scrape_me(url) — site-specific scraper (best quality) 2. fetch html + scrape_html(html, org_url, supported_only=False) — generic JSON-LD/microdata pass for unsupported sites Caught at first dogfood test against allrecipes; previous code raised "unexpected keyword argument 'wild_mode'" before issuing any HTTP. --- cauldron/discover_recipes.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/cauldron/discover_recipes.py b/cauldron/discover_recipes.py index 13fe457..a58c88b 100644 --- a/cauldron/discover_recipes.py +++ b/cauldron/discover_recipes.py @@ -146,10 +146,28 @@ def _scrape_one(url: str) -> tuple[dict, str | None] | None: return None try: - scraper = scrape_me(url, wild_mode=True) + scraper = scrape_me(url) except Exception as e: - log.warning("[discover] scrape_me(%s) failed: %s", url, e) - return None + # scraper_exists_for is False or the request failed. + # Fall back to scrape_html with supported_only=False so unknown + # sites still get a JSON-LD/microdata pass. + try: + from recipe_scrapers import scrape_html # type: ignore + import requests as _rq + resp = _rq.get( + url, + timeout=15, + headers={"User-Agent": "Mozilla/5.0 (cauldron-discover)"}, + ) + if resp.status_code != 200: + log.warning("[discover] fetch %s -> %s", url, resp.status_code) + return None + scraper = scrape_html( + html=resp.text, org_url=url, supported_only=False + ) + except Exception as e2: + log.warning("[discover] scrape_me(%s) failed: %s / fallback: %s", url, e, e2) + return None shaped = _to_mealie_shape(scraper, url) image = shaped.get("image") or None