fix: check for existing items

This commit is contained in:
Ben Goldsworthy 2024-03-17 13:54:15 +00:00
parent 5120d13117
commit 5bac2211fe
Signed by: Rumperuu
SSH key fingerprint: SHA256:v3uompaUiPqV2w1/AIRWBSQOxr2dntH9Xs/y8fDnUPU

View file

@ -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 = 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:
if "ol_id" in item:
new_item, log_to_delete = check_for_existing(item["ol_id"], media_type, log)
if new_item is None:
if "isbn_13" in item:
new_item, log_to_delete = check_for_existing(
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"]: