From c94b08cecbe140fd9f25e4789f111f7b1c340c8d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 19 Sep 2021 15:34:54 +0100 Subject: [PATCH] Share image url --- shares.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shares.py b/shares.py index 947427361..698b25ca2 100644 --- a/shares.py +++ b/shares.py @@ -1365,7 +1365,8 @@ def sharesCatalogCSVEndpoint(baseDir: str, httpPrefix: str, csvStr += str(item['DFC:quantity']) + ',' csvStr += item['DFC:price'].split(' ')[0] + ',' csvStr += '"' + item['DFC:price'].split(' ')[1] + '",' - csvStr += '"' + item['DFC:Image'] + '",' + if item.get('DFC:Image'): + csvStr += '"' + item['DFC:Image'] + '",' description = item['DFC:description'].replace('"', "'") csvStr += '"' + description + '",\n' return csvStr @@ -1776,7 +1777,6 @@ def _dfcToSharesFormat(catalogJson: {}, not item.get('DFC:expiryDate') or \ not item.get('DFC:quantity') or \ not item.get('DFC:price') or \ - not item.get('DFC:Image') or \ not item.get('DFC:description'): continue @@ -1825,10 +1825,13 @@ def _dfcToSharesFormat(catalogJson: {}, itemID = item['@id'] description = item['DFC:description'].split(':', 1)[1].strip() + imageUrl = '' + if item.get('DFC:Image'): + imageUrl = item['DFC:Image'] sharesJson[itemID] = { "displayName": item['DFC:description'].split(':')[0], "summary": description, - "imageUrl": item['DFC:Image'], + "imageUrl": imageUrl, "itemQty": float(item['DFC:quantity']), "dfcId": dfcId, "itemType": itemType,