def create_otio_reference(media_pool_item):
    metadata = _get_metadata_media_pool_item(media_pool_item)
    mp_clip_property = media_pool_item.GetClipProperty()
    path = mp_clip_property['File Path']
    reformat_path = utils.get_reformated_path(path, padded=True)
    padding = utils.get_padding_from_path(path)
    if padding:
        metadata.update({'isSequence': True, 'padding': padding})
    mp_clip_property = media_pool_item.GetClipProperty()
    fps = float(mp_clip_property['FPS'])
    if (mp_clip_property['Type'] == 'Video'):
        frame_start = int(mp_clip_property['Start'])
        frame_duration = int(mp_clip_property['Frames'])
    else:
        audio_duration = str(mp_clip_property['Duration'])
        frame_start = 0
        frame_duration = int(utils.timecode_to_frames(audio_duration, float(fps)))
    otio_ex_ref_item = None
    if padding:
        try:
            (dirname, filename) = os.path.split(path)
            collection = clique.parse(filename, '{head}[{ranges}]{tail}')
            padding_num = len(re.findall('(\\d+)(?=-)', filename).pop())
            otio_ex_ref_item = otio.schema.ImageSequenceReference(target_url_base=(dirname + os.sep), name_prefix=collection.format('{head}'), name_suffix=collection.format('{tail}'), start_frame=frame_start, frame_zero_padding=padding_num, rate=fps, available_range=create_otio_time_range(frame_start, frame_duration, fps))
        except AttributeError:
            pass
    if (not otio_ex_ref_item):
        otio_ex_ref_item = otio.schema.ExternalReference(target_url=reformat_path, available_range=create_otio_time_range(frame_start, frame_duration, fps))
    add_otio_metadata(otio_ex_ref_item, media_pool_item, **metadata)
    return otio_ex_ref_item
def create_otio_reference(media_pool_item):
    metadata = _get_metadata_media_pool_item(media_pool_item)
    mp_clip_property = media_pool_item.GetClipProperty()
    path = mp_clip_property['File Path']
    reformat_path = utils.get_reformated_path(path, padded=True)
    padding = utils.get_padding_from_path(path)
    if padding:
        metadata.update({'isSequence': True, 'padding': padding})
    mp_clip_property = media_pool_item.GetClipProperty()
    fps = float(mp_clip_property['FPS'])
    if (mp_clip_property['Type'] == 'Video'):
        frame_start = int(mp_clip_property['Start'])
        frame_duration = int(mp_clip_property['Frames'])
    else:
        audio_duration = str(mp_clip_property['Duration'])
        frame_start = 0
        frame_duration = int(utils.timecode_to_frames(audio_duration, float(fps)))
    otio_ex_ref_item = None
    if padding:
        try:
            (dirname, filename) = os.path.split(path)
            collection = clique.parse(filename, '{head}[{ranges}]{tail}')
            padding_num = len(re.findall('(\\d+)(?=-)', filename).pop())
            otio_ex_ref_item = otio.schema.ImageSequenceReference(target_url_base=(dirname + os.sep), name_prefix=collection.format('{head}'), name_suffix=collection.format('{tail}'), start_frame=frame_start, frame_zero_padding=padding_num, rate=fps, available_range=create_otio_time_range(frame_start, frame_duration, fps))
        except AttributeError:
            pass
    if (not otio_ex_ref_item):
        otio_ex_ref_item = otio.schema.ExternalReference(target_url=reformat_path, available_range=create_otio_time_range(frame_start, frame_duration, fps))
    add_otio_metadata(otio_ex_ref_item, media_pool_item, **metadata)
    return otio_ex_ref_item