[books] Fix resume reading link and page calc
All checks were successful
build & deploy / test (push) Successful in 1m44s
build & deploy / build-and-deploy (push) Successful in 33s

This commit is contained in:
2026-05-19 21:03:42 -04:00
parent af8b1d4f8a
commit 217e2443e2
4 changed files with 63 additions and 34 deletions

View File

@ -768,7 +768,25 @@ def scrobble_start(request, uuid):
scrobble = None
user_id = request.user.id
if media_obj:
media_obj.scrobble_for_user(user_id)
log_data = None
if (
request.GET.get("resume")
and media_obj.__class__.__name__ == Scrobble.MediaType.BOOK
):
last_scrobble = (
Scrobble.objects.filter(
book=media_obj,
user_id=user_id,
)
.filter(Q(long_play_complete=False) | Q(long_play_complete__isnull=True))
.filter(log__page_end__isnull=False)
.order_by("-timestamp")
.first()
)
if last_scrobble and last_scrobble.logdata:
next_page = last_scrobble.logdata.page_end + 1
log_data = {"page_start": next_page}
media_obj.scrobble_for_user(user_id, log=log_data)
if scrobble:
messages.add_message(