diff --git a/scripts/add_item.py b/scripts/add_item.py index 2b2ba09..92c2bd3 100644 --- a/scripts/add_item.py +++ b/scripts/add_item.py @@ -178,19 +178,28 @@ def add_item_to_log(item_id: str, media_type: str, log: str) -> None: raise Exception("No item found") if "books" == media_type: - new_item, log_to_delete = check_for_existing( - item["work"]["ol_id"], media_type, log - ) + new_item = None + if "work" in "ol_id": + new_item, log_to_delete = check_for_existing( + item["work"]["ol_id"], media_type, log + ) + if new_item is None: - new_item, log_to_delete = check_for_existing(item["ol_id"], media_type, log) + if "ol_id" in item: + new_item, log_to_delete = check_for_existing(item["ol_id"], media_type, log) + if new_item is None: - new_item, log_to_delete = check_for_existing( - item["isbn_13"], media_type, log - ) - if new_item is None: + if "isbn_13" in item: new_item, log_to_delete = check_for_existing( - item["isbn_10"], media_type, log + item["isbn_13"], media_type, log ) + + if new_item is None: + if "isbn_10" in item: + new_item, log_to_delete = check_for_existing( + item["isbn_10"], media_type, log + ) + item = new_item if new_item is not None else item if log in ["log", "current"]: