From d229f71151f868845b76de264f9ae09c3a518160 Mon Sep 17 00:00:00 2001 From: leahjessie <740226+leahjessie@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:34:46 -0800 Subject: [PATCH 1/2] Fix Kobo "Return to last page read" popup caused by float/int mismatch --- cps/kobo.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cps/kobo.py b/cps/kobo.py index da9c9bc55..4427bff58 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -887,14 +887,21 @@ def get_statistics_response(statistics): return resp +def _clean_progress(value): + """Return progress as int if it's a whole number, preserving Kobo device expectations.""" + if value is not None and value == int(value): + return int(value) + return value + + def get_current_bookmark_response(current_bookmark): resp = { "LastModified": convert_to_kobo_timestamp_string(current_bookmark.last_modified), } if current_bookmark.progress_percent: - resp["ProgressPercent"] = current_bookmark.progress_percent + resp["ProgressPercent"] = _clean_progress(current_bookmark.progress_percent) if current_bookmark.content_source_progress_percent: - resp["ContentSourceProgressPercent"] = current_bookmark.content_source_progress_percent + resp["ContentSourceProgressPercent"] = _clean_progress(current_bookmark.content_source_progress_percent) if current_bookmark.location_value: resp["Location"] = { "Value": current_bookmark.location_value, From a4bf028537aafc469d0a0878b0cb22a452e9d6c3 Mon Sep 17 00:00:00 2001 From: leahjessie <740226+leahjessie@users.noreply.github.com> Date: Fri, 20 Feb 2026 15:34:25 -0800 Subject: [PATCH 2/2] Fix Kobo popup when ProgressPercent is 0 by using is-not-None check instead of truthiness --- cps/kobo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cps/kobo.py b/cps/kobo.py index 4427bff58..d8ef42efc 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -898,9 +898,9 @@ def get_current_bookmark_response(current_bookmark): resp = { "LastModified": convert_to_kobo_timestamp_string(current_bookmark.last_modified), } - if current_bookmark.progress_percent: + if current_bookmark.progress_percent is not None: resp["ProgressPercent"] = _clean_progress(current_bookmark.progress_percent) - if current_bookmark.content_source_progress_percent: + if current_bookmark.content_source_progress_percent is not None: resp["ContentSourceProgressPercent"] = _clean_progress(current_bookmark.content_source_progress_percent) if current_bookmark.location_value: resp["Location"] = {