scripts.shopify.remove_extra_images¶
Deletes every image but the first from every Shopify product.
uv run python -m scripts.shopify.remove_extra_images (or make
remove-extra-images). A product shows exactly one image: the Model’s first
“Photo neuve”. create_product_shopify and update_product used to also
upload the other “Photo neuve” attachments and a unit’s “Photos marketplace”;
this removes those from products already online, in one pass.
The image kept is the one at position 1 – the first one uploaded, i.e. the
first “Photo neuve”. On each product changed, the
custom.images_airtable_ids metafield update_product diffs against is
trimmed to its first line too, so the next update_product run sees the
images as up to date instead of re-uploading the same picture.
Products with at most one image are skipped, so a rerun is a no-op. Prints a
plan and asks for a typed confirmation before deleting anything, unless
--yes is given; --dry-run only prints the plan.
Attributes¶
Classes¶
Functions¶
|
|
|
Keeps only the first attachment id; None on success, else the error. |
|
Deletes every image but the first; returns the errors. |
|
|
|
Module Contents¶
- scripts.shopify.remove_extra_images.NAMESPACE = 'custom'¶
- scripts.shopify.remove_extra_images.SOURCE_KEY = 'images_airtable_ids'¶
- scripts.shopify.remove_extra_images.REQUEST_DELAY_SECONDS = 0.5¶
- scripts.shopify.remove_extra_images.MAX_RETRIES = 5¶
- class scripts.shopify.remove_extra_images.Rest(domain: str, token: str, api_version: str)¶
- base_url¶
- token¶
- scripts.shopify.remove_extra_images.trim_source_metafield(rest: Rest, product: Product) str | None¶
Keeps only the first attachment id; None on success, else the error.
- scripts.shopify.remove_extra_images.clean(rest: Rest, product: Product) list[str]¶
Deletes every image but the first; returns the errors.
- scripts.shopify.remove_extra_images.parse_args(argv: collections.abc.Sequence[str] | None = None) argparse.Namespace¶
- scripts.shopify.remove_extra_images.main(argv: collections.abc.Sequence[str] | None = None) int¶