Merge remote-tracking branch 'kobo_sync/pr/fix-kobo-progress'

This commit is contained in:
Ozzie Isaacs
2026-02-21 09:31:56 +01:00

View File

@@ -894,14 +894,21 @@ def get_statistics_response(statistics):
return resp 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): def get_current_bookmark_response(current_bookmark):
resp = { resp = {
"LastModified": convert_to_kobo_timestamp_string(current_bookmark.last_modified), "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"] = current_bookmark.progress_percent 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"] = current_bookmark.content_source_progress_percent resp["ContentSourceProgressPercent"] = _clean_progress(current_bookmark.content_source_progress_percent)
if current_bookmark.location_value: if current_bookmark.location_value:
resp["Location"] = { resp["Location"] = {
"Value": current_bookmark.location_value, "Value": current_bookmark.location_value,