From 2d1618dc1c7b63073d89f65dc3835d7f9ca85d5b Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Sat, 14 Mar 2026 20:22:15 -0700 Subject: [PATCH] Fetch food photos from ordering platform after menu extraction - Pass platform URLs from discovery to extraction phase - Call platform_images mode with stealth Playwright - Fuzzy match platform images to extracted items by name - Show progress during image fetching Co-Authored-By: Claude Opus 4.6 --- portal/setup-wizard.html | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/portal/setup-wizard.html b/portal/setup-wizard.html index 6a171bb..49bf0c6 100644 --- a/portal/setup-wizard.html +++ b/portal/setup-wizard.html @@ -1428,8 +1428,9 @@ const menuPages = discoverResult.menuPages || []; const siteName = discoverResult.siteName || ''; - // Store business info from discovery (JSON-LD, meta tags, etc.) + // Store business info and platform URLs from discovery config.discoveredBusinessInfo = discoverResult.businessInfo || {}; + config.platformPages = discoverResult.platformPages || []; if (menuPages.length > 1) { // Multiple menus found — show confirmation step @@ -1572,6 +1573,43 @@ .join('; '); } + // Fetch images from ordering platform (stealth Playwright) + const platformUrl = (config.platformPages || [])[0] || ''; + let platformImageMap = {}; + if (platformUrl && allItems.length > 0) { + document.getElementById('conversation').innerHTML = ''; + addMessage('ai', ` +
+
+ Grabbing food photos from ordering platform... +
+ `); + + try { + const imgResp = await fetch(`${config.apiBaseUrl}/setup/analyzeMenuUrl.php`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ mode: 'platform_images', url: platformUrl, items: allItems.map(i => i.name) }) + }); + const imgResult = await imgResp.json(); + if (imgResult.OK && imgResult.imageMap) { + platformImageMap = imgResult.imageMap; + const matchCount = Object.keys(platformImageMap).length; + // Match images to items by name + let matched = 0; + allItems.forEach(item => { + if (platformImageMap[item.name]) { + item.imageUrl = platformImageMap[item.name]; + matched++; + } + }); + console.log(`Platform images: ${matchCount} found, ${matched} matched to items`); + } + } catch (err) { + console.error('Platform image fetch error:', err); + } + } + // Build final combined data document.getElementById('conversation').innerHTML = ''; config.extractedData = { @@ -1589,9 +1627,11 @@ const totalItems = allItems.length; const totalCats = allCategories.length; + const imgCount = allItems.filter(i => i.imageUrl).length; const schedSummary = allMenus.filter(m => m.schedule).map(m => `${m.name}: ${m.schedule}`).join(', '); addMessage('ai', `

Done! Found ${totalItems} items across ${totalCats} categories in ${allMenus.length} menus.

+ ${imgCount ? `

${imgCount} item images found

` : ''} ${schedSummary ? `

${schedSummary}

` : ''} `);