View Single Post
Old 05-29-2023, 11:06 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
To search for any isbn that isn't an ISBN-13 (isn't 13 characters long), put this in the search bar. It is a regular expression search that matches any 13-long ISBN, then negates the match. See the calibre manual for search expression syntax.
Code:
not identifiers:isbn:~^.{13}$
This python template converts ISBN-10 values to ISBN-13, or at least it does for the few tests I ran. You can use it in the Action Chains plugin using a Single Field Edit to convert the value for specific books. Ask in that thread if you need help.
Code:
python:
def evaluate(book, context):
	isbn = book.get('identifiers').get('isbn', '')
	isbn = isbn.strip('-')
	if len(isbn) == 10: # poor man's isbn-10 validation.
		isbn = '978' + isbn[:-1]
		chk = sum(int(c) for c in isbn[0::2]) + sum(int(c)*3 for c in isbn[1::2])
		isbn += str((10 - (chk % 10)) % 10)
	return isbn
chaley is offline   Reply With Quote