From 0fede269b1deea30f5b51a8ef2b5f34904f96b0d Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Mon, 16 Jan 2023 17:52:07 -0500 Subject: [PATCH] Fix checking for completion percentages --- vrobbler/apps/scrobbles/models.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 33af3ae..ba29e08 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -40,26 +40,20 @@ class Scrobble(TimeStampedModel): @property def percent_played(self) -> int: - playback_ticks = None - percent_played = 100 - if not self.media_obj.run_time_ticks: logger.warning( f"{self} has no run_time_ticks value, cannot show percent played" ) - return percent_played + return 100 playback_ticks = self.playback_position_ticks if not playback_ticks: - logger.info( - "No playback_position_ticks, estimating based on creation time" - ) playback_ticks = (timezone.now() - self.timestamp).seconds * 1000 - percent = int((playback_ticks / self.media_obj.run_time_ticks) * 100) + if self.played_to_completion: + playback_ticks = self.media_obj.run_time_ticks - if percent > 100: - percent = 100 + percent = int((playback_ticks / self.media_obj.run_time_ticks) * 100) return percent @property