From 2a7a53ced219a07df2b7f87471e1dd9a00afb86a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 31 Jan 2020 15:48:43 +0100 Subject: [PATCH] don't let soma loop short sounds --- nonstop/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nonstop/utils.py b/nonstop/utils.py index 9a278f3..806fb12 100644 --- a/nonstop/utils.py +++ b/nonstop/utils.py @@ -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']) -- 2.39.2