From 92d8d439e2261cbe76b14b06df18719ae1ae6aa7 Mon Sep 17 00:00:00 2001 From: Victor Efimov Date: Sat, 18 Oct 2014 10:40:27 +1100 Subject: [PATCH] Fix incorrect linking for groups outside of dest audio range Might ignore a group if the last event was linked, even if the group was a valid target otherwise --- sushi.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sushi.py b/sushi.py index aa1e1b8..d92c38c 100644 --- a/sushi.py +++ b/sushi.py @@ -396,9 +396,12 @@ def calculate_shifts(src_stream, dst_stream, events, chapter_times, window, max_ # make sure we don't crash because lines aren't present in the destination stream if start_point > dst_stream.duration_seconds: logging.info('Search start point is larger than dst stream duration, ignoring: %s' % unicode(search_group[0])) - link_to = next(x for x in reversed(search_groups[:idx]) if not x[-1].linked)[-1] - for e in search_group: - e.link_event(link_to) + for group in reversed(passed_groups[:idx]): + link_to = next((x for x in reversed(group) if not x.linked), None) + if link_to: + for e in search_group: + e.link_event(link_to) + break continue # searching with smaller window