feat: duplicate detection + original URL in description
- Add original recipe URL to Mealie description (appended after blank line) - Check for duplicate recipes on scrape (match orgURL or URL in description) - Show warning with link to existing recipe if duplicate found - User can still import anyway (warning only, not blocking) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-1
@@ -81,7 +81,19 @@ def scrape_url():
|
||||
return jsonify({"ok": False, "error": "Nincs URL megadva."})
|
||||
try:
|
||||
data = scrape(url)
|
||||
return jsonify({"ok": True, "data": data})
|
||||
|
||||
# Check for duplicate in Mealie
|
||||
duplicate = None
|
||||
cfg = config.load()
|
||||
if cfg.get("mealie_url") and cfg.get("mealie_api_key"):
|
||||
try:
|
||||
client = MealieClient(cfg["mealie_url"], cfg["mealie_api_key"],
|
||||
api_url=config.MEALIE_INTERNAL_URL)
|
||||
duplicate = client.find_duplicate(url, data.get("title", ""))
|
||||
except Exception:
|
||||
pass # non-fatal
|
||||
|
||||
return jsonify({"ok": True, "data": data, "duplicate": duplicate})
|
||||
except Exception as exc:
|
||||
return jsonify({"ok": False, "error": str(exc), "trace": traceback.format_exc()})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user