def create_otio_timeline(resolve_project):
    self.project_fps = resolve_project.GetSetting('timelineFrameRate')
    timeline = resolve_project.GetCurrentTimeline()
    otio_timeline = _create_otio_timeline(resolve_project, timeline, self.project_fps)
    for track_type in list(self.track_types.keys()):
        track_count = timeline.GetTrackCount(track_type)
        for track_index in range(1, (int(track_count) + 1)):
            track_name = timeline.GetTrackName(track_type, track_index)
            otio_track = create_otio_track(track_type, track_name)
            current_track_items = timeline.GetItemListInTrack(track_type, track_index)
            for track_item in current_track_items:
                if (track_item.GetMediaPoolItem() is None):
                    continue
                clip_start = (track_item.GetStart() - timeline.GetStartFrame())
                add_otio_gap(clip_start, otio_track, track_item, timeline)
                otio_clip = create_otio_clip(track_item)
                if (not isinstance(otio_clip, list)):
                    otio_track.append(otio_clip)
                else:
                    for (index, clip) in enumerate(otio_clip):
                        if (index == 0):
                            otio_track.append(clip)
                        else:
                            otio_timeline.tracks.append(otio_track)
                            otio_track = create_otio_track(track_type, track_name)
                            add_otio_gap(clip_start, otio_track, track_item, timeline)
                            otio_track.append(clip)
            otio_timeline.tracks.append(otio_track)
    return otio_timeline
def create_otio_timeline(resolve_project):
    self.project_fps = resolve_project.GetSetting('timelineFrameRate')
    timeline = resolve_project.GetCurrentTimeline()
    otio_timeline = _create_otio_timeline(resolve_project, timeline, self.project_fps)
    for track_type in list(self.track_types.keys()):
        track_count = timeline.GetTrackCount(track_type)
        for track_index in range(1, (int(track_count) + 1)):
            track_name = timeline.GetTrackName(track_type, track_index)
            otio_track = create_otio_track(track_type, track_name)
            current_track_items = timeline.GetItemListInTrack(track_type, track_index)
            for track_item in current_track_items:
                if (track_item.GetMediaPoolItem() is None):
                    continue
                clip_start = (track_item.GetStart() - timeline.GetStartFrame())
                add_otio_gap(clip_start, otio_track, track_item, timeline)
                otio_clip = create_otio_clip(track_item)
                if (not isinstance(otio_clip, list)):
                    otio_track.append(otio_clip)
                else:
                    for (index, clip) in enumerate(otio_clip):
                        if (index == 0):
                            otio_track.append(clip)
                        else:
                            otio_timeline.tracks.append(otio_track)
                            otio_track = create_otio_track(track_type, track_name)
                            add_otio_gap(clip_start, otio_track, track_item, timeline)
                            otio_track.append(clip)
            otio_timeline.tracks.append(otio_track)
    return otio_timeline