Skip to content

Commit 15c29b5

Browse files
Rodeofx fix cmx 3600 multiple markers per clip issue 593 (#664)
* Support multiple markers per clip for cmx_3600 adapter (issue-593) * Remove unnecessary indentation, adjust test for multiple markers * Adjust no_spaces_test.edl to match the changes made to screening_example.edl Co-authored-by: Emile Labrosse <[email protected]>
1 parent 94597bf commit 15c29b5

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

src/py-opentimelineio/opentimelineio/adapters/cmx_3600.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def make_clip(self, comment_data):
450450
}
451451
}
452452

453-
if 'locator' in comment_data:
453+
if 'locators' in comment_data:
454454
# An example EDL locator line looks like this:
455455
# * LOC: 01:00:01:14 RED ANIM FIX NEEDED
456456
# We get the part after "LOC: " as the comment_data entry
@@ -459,11 +459,15 @@ def make_clip(self, comment_data):
459459
# variations of EDL, so if we are lenient then maybe we
460460
# can handle more of them? Only real-world testing will
461461
# determine this for sure...
462-
m = re.match(
463-
r'(\d\d:\d\d:\d\d:\d\d)\s+(\w*)(\s+|$)(.*)',
464-
comment_data["locator"]
465-
)
466-
if m:
462+
for locator in comment_data['locators']:
463+
m = re.match(
464+
r'(\d\d:\d\d:\d\d:\d\d)\s+(\w*)(\s+|$)(.*)',
465+
locator
466+
)
467+
if not m:
468+
# TODO: Should we report this as a warning somehow?
469+
continue
470+
467471
marker = schema.Marker()
468472
marker.marked_range = opentime.TimeRange(
469473
start_time=opentime.from_timecode(
@@ -477,7 +481,6 @@ def make_clip(self, comment_data):
477481
# is not a valid enum somehow.
478482
color_parsed_from_file = m.group(2)
479483

480-
marker.metadata.clear()
481484
marker.metadata.update({
482485
"cmx_3600": {
483486
"color": color_parsed_from_file
@@ -495,9 +498,6 @@ def make_clip(self, comment_data):
495498

496499
marker.name = m.group(4)
497500
clip.markers.append(marker)
498-
else:
499-
# TODO: Should we report this as a warning somehow?
500-
pass
501501

502502
clip.source_range = opentime.range_from_start_end_time(
503503
opentime.from_timecode(self.source_tc_in, self.edl_rate),
@@ -580,7 +580,7 @@ class CommentHandler(object):
580580
('FROM CLIP NAME', 'clip_name'),
581581
('FROM CLIP', 'media_reference'),
582582
('FROM FILE', 'media_reference'),
583-
('LOC', 'locator'),
583+
('LOC', 'locators'),
584584
('ASC_SOP', 'asc_sop'),
585585
('ASC_SAT', 'asc_sat'),
586586
('M2', 'motion_effect'),
@@ -598,9 +598,18 @@ def parse(self, comment):
598598
regex = self.regex_template.format(id=comment_id)
599599
match = re.match(regex, comment)
600600
if match:
601-
self.handled[comment_type] = match.group(
602-
'comment_body'
603-
).strip()
601+
comment_body = match.group('comment_body').strip()
602+
603+
# Special case for locators. There can be multiple locators per clip.
604+
if comment_type == 'locators':
605+
try:
606+
self.handled[comment_type].append(comment_body)
607+
except KeyError:
608+
self.handled[comment_type] = [comment_body]
609+
610+
else:
611+
self.handled[comment_type] = comment_body
612+
604613
break
605614
else:
606615
stripped = comment.lstrip('*').strip()

tests/sample_data/no_spaces_test.edl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ FCM: NON-DROP FRAME
1111
*SOURCE FILE: ZZ100_503A.LAY1.01
1212
004 ZZ100_50 V C 01:00:10:01 01:00:14:20 00:59:58:00 01:00:02:19
1313
*FROM CLIP NAME: ZZ100_504C (LAY1)
14-
*LOC: 01:00:01:14 RED ANIM FIX NEEDED
14+
*LOC: 01:00:01:14 RED ANIM FIX NEEDED
15+
*LOC: 01:00:02:14 PINK ANIM FIX NEEDED
1516
*SOURCE FILE: ZZ100_504C.LAY1.02
1617
005 ZZ100_50 V C 01:00:14:17 01:00:18:22 01:00:02:19 01:00:07:00
1718
*FROM CLIP NAME: ZZ100_504B (LAY1)

tests/sample_data/screening_example.edl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ FCM: NON-DROP FRAME
1414
* SOURCE FILE: ZZ100_503A.LAY1.01
1515
004 ZZ100_50 V C 01:00:10:01 01:00:14:20 00:59:58:00 01:00:02:19
1616
* FROM CLIP NAME: ZZ100_504C (LAY1)
17-
* LOC: 01:00:01:14 RED ANIM FIX NEEDED
17+
* LOC: 01:00:01:14 RED ANIM FIX NEEDED
18+
* LOC: 01:00:02:14 PINK ANIM FIX NEEDED
1819
* SOURCE FILE: ZZ100_504C.LAY1.02
1920
005 ZZ100_50 V C 01:00:14:17 01:00:18:22 01:00:02:19 01:00:07:00
2021
* FROM CLIP NAME: ZZ100_504B (LAY1)

tests/test_cmx_3600_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_edl_read(self):
9494
otio.opentime.from_timecode("00:00:04:19", fps)
9595
)
9696

97-
self.assertEqual(len(timeline.tracks[0][3].markers), 1)
97+
self.assertEqual(len(timeline.tracks[0][3].markers), 2)
9898
marker = timeline.tracks[0][3].markers[0]
9999
self.assertEqual(marker.name, "ANIM FIX NEEDED")
100100
self.assertEqual(marker.metadata.get("cmx_3600").get("color"), "RED")

0 commit comments

Comments
 (0)