diff --git a/vrobbler/apps/books/models.py b/vrobbler/apps/books/models.py index de2b70b..337c87c 100644 --- a/vrobbler/apps/books/models.py +++ b/vrobbler/apps/books/models.py @@ -62,7 +62,8 @@ class BookLogData(BaseLogData, LongPlayLogData): pages_read: Optional[int] = None page_start: Optional[int] = None page_end: Optional[int] = None - bookmark_url: Optional[str] = None + resume_url: Optional[str] = None + restart_url: Optional[str] = None _excluded_fields = {"koreader_hash", "page_data"} diff --git a/vrobbler/apps/scrobbles/scrobblers.py b/vrobbler/apps/scrobbles/scrobblers.py index e9dc06a..7a852b4 100644 --- a/vrobbler/apps/scrobbles/scrobblers.py +++ b/vrobbler/apps/scrobbles/scrobblers.py @@ -312,7 +312,8 @@ def manual_scrobble_book( if action == "stop": if url: - scrobble.log["bookmark_url"] = url + scrobble.log["resume_url"] = url + scrobble.log["restart_url"] = remove_last_part(url) scrobble.save(update_fields=["log"]) scrobble.stop(force_finish=True) diff --git a/vrobbler/apps/scrobbles/utils.py b/vrobbler/apps/scrobbles/utils.py index ac86271..c4dbd61 100644 --- a/vrobbler/apps/scrobbles/utils.py +++ b/vrobbler/apps/scrobbles/utils.py @@ -408,3 +408,9 @@ def get_daily_calorie_dict_for_user(user_id: int) -> dict[date, int]: ) return {entry["day"]: entry["total_calories"] for entry in qs} + +def remove_last_part(url: str) -> str: + url = url.rstrip('/') + if '/' not in url: + return url + return url.rsplit('/', 1)[0] diff --git a/vrobbler/templates/books/book_detail.html b/vrobbler/templates/books/book_detail.html index 818415e..3772adb 100644 --- a/vrobbler/templates/books/book_detail.html +++ b/vrobbler/templates/books/book_detail.html @@ -29,7 +29,8 @@
{{scrobbles.count}} scrobbles
{% for s in scrobbles %} {% if forloop.first %} - + + {% endif %} {% endfor %}