]> git.0d.be Git - django-panik-nonstop.git/commitdiff
don't let soma loop short sounds
authorFrédéric Péters <fpeters@0d.be>
Fri, 31 Jan 2020 14:48:43 +0000 (15:48 +0100)
committerFrédéric Péters <fpeters@0d.be>
Fri, 31 Jan 2020 14:48:43 +0000 (15:48 +0100)
nonstop/utils.py

index 9a278f30e310088511a66338d6d03aeff8aa425b..806fb12467c03422c16965e762fd825d0c6fe5fb 100644 (file)
@@ -86,8 +86,10 @@ def add_diffusion(diffusion, **kwargs):
 
         context['diffusion_path'] = diffusion_path
         # end should be a bit before the real end of file so the same file doesn't
-        # get repeated.
-        context['end'] = diffusion.datetime + datetime.timedelta(seconds=(soundfile.duration or 300) - 180)
+        # get repeated but shouldn't be less or equal than start date or soma would
+        # loop the file
+        context['end'] = diffusion.datetime + datetime.timedelta(seconds=
+                max(((soundfile.duration or 300) - 180), 60))
 
         if 'jingle_id' in kwargs:
             context['jingle'] = Jingle.objects.get(id=kwargs['jingle_id'])