diff --git a/agent.md b/agent.md index 07b5e68..d347430 100644 --- a/agent.md +++ b/agent.md @@ -193,6 +193,7 @@ There are three selectable data sources: - Review UI: show picture size, source, target assignment, duplicate state, per-row save and batch save actions. - Hudy picture parsing uses the correct product color variant, checks EANs and extracts large gallery images. - Idealo uses the browser adapter and is intended mainly as a picture source. +- Idealo picture parsing must read product gallery images from Splide gallery markup (`splide__track`, `splide__list`, `splide__slide`) and choose the largest available URL from `srcset`, `data-srcset`, `data-large`, `data-original`, `data-src` or `src`. Do not use search-result thumbnails or small preview URLs as production picture candidates when gallery images exist. - Image preview is square. - Settings is at the bottom of the left panel; database status is directly above it. diff --git a/src/services/catalog-products.ts b/src/services/catalog-products.ts index 3605004..1395ee5 100644 --- a/src/services/catalog-products.ts +++ b/src/services/catalog-products.ts @@ -310,7 +310,11 @@ async function findSourceCandidates(source, product, { includePictures = false } attempt, product, ); - if (includePictures) candidate.pictures = extractPictureUrls(result.pageSource, result.url || attempt.url); + if (includePictures) { + candidate.pictures = source.key === "idealo" + ? extractIdealoGalleryPictureUrls(result.pageSource, result.url || attempt.url) + : extractPictureUrls(result.pageSource, result.url || attempt.url); + } return { source, query: attempt.query, @@ -381,6 +385,8 @@ async function findSourceCandidates(source, product, { includePictures = false } for (const candidate of candidates) { if (source.key === "hudy" && candidate.url) { candidate.pictures = await extractPicturesFromPage(candidate.url, source.browserEngine); + } else if (source.key === "idealo") { + candidate.pictures = extractIdealoGalleryPictureUrls(html, response.url || attempt.url); } else { candidate.pictures = extractPictureUrls(html, response.url || attempt.url); } @@ -742,6 +748,108 @@ function extractPictureUrls(html, pageUrl) { return urls.slice(0, 12); } +export function extractIdealoGalleryPictureUrls(html, pageUrl) { + const source = String(html ?? ""); + const galleryMatches = [ + ...source.matchAll(/