def get_cover_id(olkeys): """Return the first cover from the list of ol keys.""" for olkey in olkeys: doc = ol_get(olkey) if not doc: continue if doc['key'].startswith("/authors"): covers = doc.get('photos', []) else: covers = doc.get('covers', []) if covers: return covers[0]
def get_cover_id(olkeys): """Return the first cover from the list of ol keys.""" for olkey in olkeys: doc = ol_get(olkey) if not doc: continue if doc['key'].startswith("/authors"): covers = doc.get('photos', []) else: covers = doc.get('covers', []) # Sometimes covers is stored as [-1] to indicate no covers. Consider it as no covers. if covers and covers[0] >= 0: return covers[0]