Quantcast
Channel: MobileRead Forums
Viewing all articles
Browse latest Browse all 50107

Script to avoid downloading existing duplicates in calibre

$
0
0
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:
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 []

Any help is welcome to test this out.

Viewing all articles
Browse latest Browse all 50107

Latest Images

Trending Articles



Latest Images