Fix looking up book using ISBN
This commit is contained in:
@ -161,12 +161,10 @@ class Book(LongPlayScrobblableMixin):
|
|||||||
return progress
|
return progress
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_or_create(cls, data_dict: dict) -> "Game":
|
def find_or_create(cls, lookup_id: str, author: str = "") -> "Game":
|
||||||
from books.utils import update_or_create_book
|
from books.utils import update_or_create_book
|
||||||
|
|
||||||
return update_or_create_book(
|
return update_or_create_book(lookup_id, author)
|
||||||
data_dict.get("title"), data_dict.get("author")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Page(TimeStampedModel):
|
class Page(TimeStampedModel):
|
||||||
|
|||||||
@ -629,8 +629,10 @@ class Scrobble(TimeStampedModel):
|
|||||||
# to allow a scrobble to be updated.
|
# to allow a scrobble to be updated.
|
||||||
jellyfin_in_progress = scrobble_data.get("jellyfin_status", None)
|
jellyfin_in_progress = scrobble_data.get("jellyfin_status", None)
|
||||||
if scrobble and (scrobble.can_be_updated or jellyfin_in_progress):
|
if scrobble and (scrobble.can_be_updated or jellyfin_in_progress):
|
||||||
|
source = scrobble_data["source"]
|
||||||
|
mtype = media.__class__.__name__
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Updating {scrobble.id}",
|
f"[scrobbling] updating {scrobble.id} for {mtype} {media.id} from {source}",
|
||||||
{"scrobble_data": scrobble_data, "media": media},
|
{"scrobble_data": scrobble_data, "media": media},
|
||||||
)
|
)
|
||||||
return scrobble.update(scrobble_data)
|
return scrobble.update(scrobble_data)
|
||||||
|
|||||||
@ -210,8 +210,7 @@ def manual_scrobble_video_game(hltb_id: str, user_id: int):
|
|||||||
|
|
||||||
|
|
||||||
def manual_scrobble_book(openlibrary_id: str, user_id: int):
|
def manual_scrobble_book(openlibrary_id: str, user_id: int):
|
||||||
data_dict = lookup_book_from_openlibrary(openlibrary_id)
|
book = Book.find_or_create(openlibrary_id)
|
||||||
book = Book.find_or_create(data_dict)
|
|
||||||
|
|
||||||
scrobble_dict = {
|
scrobble_dict = {
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user