From 44672651684f9805135472c22784d4cdd14aff4c Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Tue, 24 Feb 2026 18:22:19 +0100 Subject: [PATCH] Detect redirect-like instructions and show warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When recipe instructions are just a link to another site (e.g. "ide kattintva, a Kiskegyed oldalán találod"), display a warning instead of silently accepting non-useful instruction text. Co-Authored-By: Claude Opus 4.6 --- app/main.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 8d8f2cc..9c72136 100644 --- a/app/main.py +++ b/app/main.py @@ -58,6 +58,18 @@ def _hash_password(password: str) -> str: return hashlib.sha256(password.encode("utf-8")).hexdigest() +_REDIRECT_PATTERNS = ["ide kattintva", "oldalán találod", "teljes recept itt", + "kattints ide", "eredeti recept"] + + +def _is_redirect_instructions(instructions: list[str]) -> bool: + """Check if instructions are just a redirect to another site.""" + if len(instructions) > 2: + return False + text = " ".join(instructions).lower() + return any(p in text for p in _REDIRECT_PATTERNS) + + # --------------------------------------------------------------------------- # Routes # --------------------------------------------------------------------------- @@ -182,8 +194,12 @@ def scrape_url(): real_ingredients = [i for i in data.get("ingredients", []) if "group" not in i] if not real_ingredients: warnings.append("A recept nem tartalmaz hozzávalókat.") - if not data.get("instructions"): + instructions = data.get("instructions", []) + if not instructions: warnings.append("A recept nem tartalmaz elkészítési lépéseket.") + elif _is_redirect_instructions(instructions): + warnings.append("Az elkészítés egy másik oldalra mutat. " + "A recept valószínűleg nem tartalmaz valódi lépéseket.") return jsonify({"ok": True, "data": data, "duplicate": duplicate, "tandoor_duplicate": tandoor_duplicate,