Fix operator precedence and inverted dedup logic in audiobooks playlog (#3153)
authorDavid Bishop <teancom@users.noreply.github.com>
Fri, 13 Feb 2026 09:53:46 +0000 (01:53 -0800)
committerGitHub <noreply@github.com>
Fri, 13 Feb 2026 09:53:46 +0000 (10:53 +0100)
commit7753e572b58b82afb508f2786a182bab07cdec31
tree8d8444e897c117550fef1087a13f7d950cec9222
parentc7b8389b509151c62ad112650c46114c4f0f76cf
Fix operator precedence and inverted dedup logic in audiobooks playlog (#3153)

Two bugs in the audiobook resume/playlog tracking:

1. `int(media_item.resume_position_ms or 0 / 1000)` never divides by
   1000 because `/` binds tighter than `or`. The expression evaluates as
   `int(resume_position_ms or (0 / 1000))`, so non-zero values pass
   through as raw milliseconds instead of seconds.

2. The dedup check `abs(difference) > 2` skips the DB write when data
   HAS changed (difference > 2 seconds) and writes when it has NOT
   changed (difference <= 2 seconds). The comparison is inverted.

Co-authored-by: David Bishop <git@gnuconsulting.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
music_assistant/controllers/media/audiobooks.py