Skip to content

Commit 852f422

Browse files
tyethclaude
andcommitted
Fix skill: scrape image URLs from product page, don't guess numbers
Image numbers on Adafruit CDN aren't contiguous — scrape all available image URLs from the product page gallery instead of iterating through a hardcoded range. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 767b4e6 commit 852f422

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

.agents/skills/add-component-v1/SKILL.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,19 @@ The definition.json must validate against `components/i2c/schema.json`. Key cons
242242

243243
**For Adafruit products:**
244244

245-
1. **From Adafruit product API:** `https://www.adafruit.com/api/product/<PID>` — the
246-
`product_image` field gives the default image URL (typically `640x480`).
245+
1. **Scrape all image URLs from the product page:** Fetch `https://www.adafruit.com/product/<PID>`
246+
and extract all `cdn-shop.adafruit.com` image URLs. The product page gallery contains every
247+
available shot — don't guess image numbers, as they are not necessarily contiguous.
247248
2. **CRITICAL — Always use the `/original/` CDN URL, NOT `970x728` or `640x480`.**
248249
The Adafruit CDN URL contains a resolution prefix. You MUST replace it with `original`
249250
to get the highest-resolution source for downscaling. Downloading a pre-scaled version
250251
(e.g. `970x728`) produces a blurry 400x300 result.
251252
- **USE THIS:** `https://cdn-shop.adafruit.com/original/<PID>-NN.jpg`
252253
- NOT: `https://cdn-shop.adafruit.com/970x728/<PID>-NN.jpg`
253254
- NOT: `https://cdn-shop.adafruit.com/640x480/<PID>-NN.jpg`
254-
- Where `NN` is the image number (`01` = default, `00` and up are common variants)
255-
- If you scraped a URL from the product page or API, replace the resolution part
255+
- For each image URL scraped from the product page, replace the resolution part
256256
(e.g. `970x728`, `640x480`) with `original` before downloading
257-
3. **Check all available shots** by incrementing from `00` until you get a 404 — pick the slight-angle / isometric
257+
3. **Check all available shots** from the scraped URLs — pick the slight-angle / isometric
258258
close-up of the breakout board with a plain background (this is the standard Adafruit product
259259
photo style, typically image `00`). Avoid lifestyle shots, shots with other boards or
260260
accessories in the frame, or images where the board is very small in the frame.
@@ -390,7 +390,7 @@ import urllib.request, io, os
390390

391391
# 1. Download original resolution source (best quality)
392392
PID = '<product_id>'
393-
IMAGE_NUM = '01' # try 00, 01, 02, ... until 404 to find best shot
393+
IMAGE_NUM = '01' # use image numbers scraped from product page
394394
url = f'https://cdn-shop.adafruit.com/original/{PID}-{IMAGE_NUM}.jpg'
395395
data = urllib.request.urlopen(url).read()
396396
img = Image.open(io.BytesIO(data))

0 commit comments

Comments
 (0)