#!/home/hermes/venv/bin/python3 """Get Lacrimosa cover image from Amazon CreatorAPI""" from amazon_creatorsapi import AmazonCreatorsApi import urllib.request, json, sys api = AmazonCreatorsApi( credential_id='amzn1.application-oa2-client.91799968d0744e66950ea413659197d4', credential_secret='amzn1.oa2-cs.v1.4c41154ecfd1835e00879ad5c8060ef5cd3b209b06077c0af1d868b343cab955', version='3.2', tag='60pro05-21', marketplace='www.amazon.de', throttling=1.0 ) # Try Kosmos German edition try: result = api.search_items(keywords='B0C7RKGFYX', item_count=1, resources=['images.primary.large', 'itemInfo.title', 'offersV2.listings.price']) d = result.model_dump() item = d['items'][0] title = item['itemInfo']['title']['displayValue'] img_url = item['images']['primary']['large']['url'] img_url_hi = img_url.replace('_SL500_', '_AC_SL1500_') print(f"TITLE: {title}") print(f"IMG_URL_SL500: {img_url}") print(f"IMG_URL_HI: {img_url_hi}") # Download hi-res urllib.request.urlretrieve(img_url_hi, '/tmp/cover_Lacrimosa.jpg') print(f"DOWNLOADED: /tmp/cover_Lacrimosa.jpg") # Check for price info if 'offersV2' in item: listings = item['offersV2'].get('listings', []) if listings: price = listings[0]['price'] print(f"PRICE: {price.get('displayAmount', '?')}") if 'savings' in price: sv = price['savings'] print(f"SAVINGS: {sv.get('percentage', '?')}% - {sv.get('displayAmount', '?')}") except Exception as e: print(f"ERROR: {e}")