X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/5715ba5816c2773949689461f715a08caa8c5d11..ba1734bdc35bfac91d5692389f2d5600e9341370:/src/archive/views.py diff --git a/src/archive/views.py b/src/archive/views.py index cafda5d..6ae2ef6 100644 --- a/src/archive/views.py +++ b/src/archive/views.py @@ -302,13 +302,12 @@ class BookView(ListView): qs = models.Audiobook.objects.filter(slug=self.kwargs["slug"]).order_by( "index" ) - total = 0 last_vol = None for b in qs: - if last_vol != b.youtube_volume: - last_vol = b.youtube_volume - total = 0 - total = b.total = total + b.duration + if last_vol is None or last_vol.youtube_volume != b.youtube_volume: + last_vol = b + b.total = 0 + last_vol.total += b.duration return list(qs)