Explorar el Código

Look in DB for book first

Colin Powell hace 1 año
padre
commit
45ddce36aa
Se han modificado 1 ficheros con 7 adiciones y 4 borrados
  1. 7 4
      vrobbler/apps/books/models.py

+ 7 - 4
vrobbler/apps/books/models.py

@@ -269,11 +269,14 @@ class Book(LongPlayScrobblableMixin):
 
     @classmethod
     def find_or_create(cls, lookup_id: str, author: str = "") -> "Book":
-        data = lookup_book_from_openlibrary(lookup_id, author)
+        book = cls.objects.filter(openlibrary_id=lookup_id).first()
 
-        book, book_created = cls.objects.get_or_create(isbn=data["isbn"])
-        if book_created:
-            book.fix_metadata(data=data)
+        if not book:
+            data = lookup_book_from_openlibrary(lookup_id, author)
+
+            book, book_created = cls.objects.get_or_create(isbn=data["isbn"])
+            if book_created:
+                book.fix_metadata(data=data)
 
         return book