From 1b7ee7b275d85ac4ad97139c4a46f80a302209e9 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 17 Feb 2024 10:52:19 +0000 Subject: [PATCH] update edit preview in backend --- pandora/mobile/views.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pandora/mobile/views.py b/pandora/mobile/views.py index 1fc87e6ff..57a190538 100644 --- a/pandora/mobile/views.py +++ b/pandora/mobile/views.py @@ -66,10 +66,25 @@ def index(request, fragment): clips = _order_clips(edit, sort) else: clips = edit.get_clips(request.user) - clip = clips.first() - if clip: - start = clip.json()['in'] - preview = '/%s/%sp%0.03f.jpg' % (clip.item.public_id, resolution, float(start)) + + preview = None + + if len(parts) >= 3 and ':' in parts[-1]: + ts = ox.parse_timecode(parts[-1]) + position = 0 + for clip in clips: + c = clip.json() + if ts > position and ts < position + c['duration']: + start = ts - position + c.get('in', 0) + preview = '/%s/%sp%0.03f.jpg' % (clip.item.public_id, resolution, float(start)) + break + position += c['duration'] + if not preview: + clip = clips.first() + if clip: + start = clip.json()['in'] + preview = '/%s/%sp%0.03f.jpg' % (clip.item.public_id, resolution, float(start)) + if preview: context['preview'] = request.build_absolute_uri(preview) else: type = 'item'