diff --git a/oml/item/models.py b/oml/item/models.py index a2b200a..72d6b8e 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -843,15 +843,17 @@ def download_cover(id): url = i.meta.get('cover') else: url = None + cover = None logger.debug('download cover %s %s', id, url) ratio = None - try: - cover = ox.net.read_url(url) - ratio = get_ratio(cover) - except: - logger.debug('unable to read cover url %s', url) - cover = None + if url: + try: + cover = ox.net.read_url(url) + ratio = get_ratio(cover) + except: + logger.debug('unable to read cover url %s', url) + cover = None with db.session(): i = Item.get(id, for_update=True) if i: