diff --git a/src/py-opentimelineio/opentimelineio/adapters/cmx_3600.py b/src/py-opentimelineio/opentimelineio/adapters/cmx_3600.py index 475c8c095..9f724837a 100644 --- a/src/py-opentimelineio/opentimelineio/adapters/cmx_3600.py +++ b/src/py-opentimelineio/opentimelineio/adapters/cmx_3600.py @@ -450,7 +450,7 @@ def make_clip(self, comment_data): } } - if 'locator' in comment_data: + if 'locators' in comment_data: # An example EDL locator line looks like this: # * LOC: 01:00:01:14 RED ANIM FIX NEEDED # We get the part after "LOC: " as the comment_data entry @@ -459,11 +459,15 @@ def make_clip(self, comment_data): # variations of EDL, so if we are lenient then maybe we # can handle more of them? Only real-world testing will # determine this for sure... - m = re.match( - r'(\d\d:\d\d:\d\d:\d\d)\s+(\w*)(\s+|$)(.*)', - comment_data["locator"] - ) - if m: + for locator in comment_data['locators']: + m = re.match( + r'(\d\d:\d\d:\d\d:\d\d)\s+(\w*)(\s+|$)(.*)', + locator + ) + if not m: + # TODO: Should we report this as a warning somehow? + continue + marker = schema.Marker() marker.marked_range = opentime.TimeRange( start_time=opentime.from_timecode( @@ -477,7 +481,6 @@ def make_clip(self, comment_data): # is not a valid enum somehow. color_parsed_from_file = m.group(2) - marker.metadata.clear() marker.metadata.update({ "cmx_3600": { "color": color_parsed_from_file @@ -495,9 +498,6 @@ def make_clip(self, comment_data): marker.name = m.group(4) clip.markers.append(marker) - else: - # TODO: Should we report this as a warning somehow? - pass clip.source_range = opentime.range_from_start_end_time( opentime.from_timecode(self.source_tc_in, self.edl_rate), @@ -580,7 +580,7 @@ class CommentHandler(object): ('FROM CLIP NAME', 'clip_name'), ('FROM CLIP', 'media_reference'), ('FROM FILE', 'media_reference'), - ('LOC', 'locator'), + ('LOC', 'locators'), ('ASC_SOP', 'asc_sop'), ('ASC_SAT', 'asc_sat'), ('M2', 'motion_effect'), @@ -598,9 +598,18 @@ def parse(self, comment): regex = self.regex_template.format(id=comment_id) match = re.match(regex, comment) if match: - self.handled[comment_type] = match.group( - 'comment_body' - ).strip() + comment_body = match.group('comment_body').strip() + + # Special case for locators. There can be multiple locators per clip. + if comment_type == 'locators': + try: + self.handled[comment_type].append(comment_body) + except KeyError: + self.handled[comment_type] = [comment_body] + + else: + self.handled[comment_type] = comment_body + break else: stripped = comment.lstrip('*').strip() diff --git a/tests/sample_data/no_spaces_test.edl b/tests/sample_data/no_spaces_test.edl index 7c86a634c..a0975f68b 100644 --- a/tests/sample_data/no_spaces_test.edl +++ b/tests/sample_data/no_spaces_test.edl @@ -11,7 +11,8 @@ FCM: NON-DROP FRAME *SOURCE FILE: ZZ100_503A.LAY1.01 004 ZZ100_50 V C 01:00:10:01 01:00:14:20 00:59:58:00 01:00:02:19 *FROM CLIP NAME: ZZ100_504C (LAY1) -*LOC: 01:00:01:14 RED ANIM FIX NEEDED +*LOC: 01:00:01:14 RED ANIM FIX NEEDED +*LOC: 01:00:02:14 PINK ANIM FIX NEEDED *SOURCE FILE: ZZ100_504C.LAY1.02 005 ZZ100_50 V C 01:00:14:17 01:00:18:22 01:00:02:19 01:00:07:00 *FROM CLIP NAME: ZZ100_504B (LAY1) diff --git a/tests/sample_data/screening_example.edl b/tests/sample_data/screening_example.edl index c03c6a182..e5c11b581 100644 --- a/tests/sample_data/screening_example.edl +++ b/tests/sample_data/screening_example.edl @@ -14,7 +14,8 @@ FCM: NON-DROP FRAME * SOURCE FILE: ZZ100_503A.LAY1.01 004 ZZ100_50 V C 01:00:10:01 01:00:14:20 00:59:58:00 01:00:02:19 * FROM CLIP NAME: ZZ100_504C (LAY1) -* LOC: 01:00:01:14 RED ANIM FIX NEEDED +* LOC: 01:00:01:14 RED ANIM FIX NEEDED +* LOC: 01:00:02:14 PINK ANIM FIX NEEDED * SOURCE FILE: ZZ100_504C.LAY1.02 005 ZZ100_50 V C 01:00:14:17 01:00:18:22 01:00:02:19 01:00:07:00 * FROM CLIP NAME: ZZ100_504B (LAY1) diff --git a/tests/test_cmx_3600_adapter.py b/tests/test_cmx_3600_adapter.py index cf0b07cc9..bebb01651 100755 --- a/tests/test_cmx_3600_adapter.py +++ b/tests/test_cmx_3600_adapter.py @@ -94,7 +94,7 @@ def test_edl_read(self): otio.opentime.from_timecode("00:00:04:19", fps) ) - self.assertEqual(len(timeline.tracks[0][3].markers), 1) + self.assertEqual(len(timeline.tracks[0][3].markers), 2) marker = timeline.tracks[0][3].markers[0] self.assertEqual(marker.name, "ANIM FIX NEEDED") self.assertEqual(marker.metadata.get("cmx_3600").get("color"), "RED")