[books] Calc run time from pages on save
All checks were successful
build & deploy / test (push) Successful in 1m52s
build & deploy / build-and-deploy (push) Successful in 27s

This commit is contained in:
2026-05-15 21:50:43 -04:00
parent bf7e5677e6
commit cd4f6ff71d

View File

@ -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):