Skip to content

Commit

Permalink
Rodeofx fix cmx 3600 multiple markers per clip issue 593 (#664)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
reinecke and elabrosseRodeofx authored Mar 17, 2020
1 parent 94597bf commit 15c29b5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
37 changes: 23 additions & 14 deletions src/py-opentimelineio/opentimelineio/adapters/cmx_3600.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -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'),
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion tests/sample_data/no_spaces_test.edl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tests/sample_data/screening_example.edl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cmx_3600_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 15c29b5

Please sign in to comment.