Fixes ranks and normalizes isbns

This commit is contained in:
Mouse Reeve 2021-04-29 11:04:14 -07:00
parent 7853610a20
commit d1b5f3b6f0

View file

@ -216,7 +216,10 @@ class Edition(Book):
# is it in the instance's preferred language? # is it in the instance's preferred language?
rank += int(bool(DEFAULT_LANGUAGE in self.languages)) rank += int(bool(DEFAULT_LANGUAGE in self.languages))
# prefer print editions # prefer print editions
rank += int(bool(self.physical_format.lower() in ["paperback", "hardcover"])) if self.physical_format:
rank += int(
bool(self.physical_format.lower() in ["paperback", "hardcover"])
)
# does it have metadata? # does it have metadata?
rank += int(bool(self.isbn_13)) rank += int(bool(self.isbn_13))
@ -236,6 +239,10 @@ class Edition(Book):
if self.isbn_10 and not self.isbn_13: if self.isbn_10 and not self.isbn_13:
self.isbn_13 = isbn_10_to_13(self.isbn_10) self.isbn_13 = isbn_10_to_13(self.isbn_10)
# normalize isbn format
self.isbn_10 = re.sub(r"[^0-9X]", "", self.isbn_10)
self.isbn_13 = re.sub(r"[^0-9X]", "", self.isbn_13)
# set rank # set rank
self.edition_rank = self.get_rank() self.edition_rank = self.get_rank()