From cd4f6ff71dda21476d3d6abca380fc7972151fee Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 15 May 2026 21:50:43 -0400 Subject: [PATCH] [books] Calc run time from pages on save --- vrobbler/apps/books/models.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vrobbler/apps/books/models.py b/vrobbler/apps/books/models.py index c928352..e0bd5fe 100644 --- a/vrobbler/apps/books/models.py +++ b/vrobbler/apps/books/models.py @@ -179,6 +179,13 @@ class Book(LongPlayScrobblableMixin): return f"{self.title} - Volume {self.volume_number}" return f"{self.title}" + def save(self, *args, **kwargs): + if self.pages: + self.base_run_time_seconds = int(self.pages) * int( + self.AVG_PAGE_READING_SECONDS + ) + super().save(*args, **kwargs) + @property def subtitle(self): return f" by {self.author}" @@ -413,11 +420,6 @@ class Book(LongPlayScrobblableMixin): fname = f"{self.title}_{self.uuid}.jpg" self.cover.save(fname, ContentFile(r.content), save=True) - if self.pages: - self.base_run_time_seconds = int(self.pages) * int( - self.AVG_PAGE_READING_SECONDS - ) - self.save() def fix_authors_metadata(self, openlibrary_author_id):