Hi, I have a script to download books that checks if they exist in Calibre, but when I add them to Calibre, Calibre shows duplicates. What could I refine for that search? What I have stipulated is this:
Any help is welcome to test this out.
Code:
# Search for exact matches in the calibre database
def find_identical_books(title):
try:
conn = sqlite3.connect(f"file:{CALIBRE_DB_PATH}?mode=ro", uri=True)
cursor = conn.cursor()
title = unicodedata.normalize("NFC", title).strip()
cursor.execute("SELECT id FROM books WHERE lower(title) = lower(?)", (title,))
result = cursor.fetchall()
conn.close()
return [r[0] for r in result] if result else []
except Exception as e:
log_message(f"⚠️ Error searching for duplicates in calibre: {e}")
return []









