def extract_multisegment_info(element, ms_parent_info):
    ms_info = ms_parent_info.copy()

    def extract_common(source):
        segment_timeline = source.find(_add_ns('SegmentTimeline'))
        if (segment_timeline is not None):
            s_e = segment_timeline.findall(_add_ns('S'))
            if s_e:
                ms_info['total_number'] = 0
                ms_info['s'] = []
                for s in s_e:
                    r = int(s.get('r', 0))
                    ms_info['total_number'] += (1 + r)
                    ms_info['s'].append({'t': int(s.get('t', 0)), 'd': int(s.attrib['d']), 'r': r})
        start_number = source.get('startNumber')
        if start_number:
            ms_info['start_number'] = int(start_number)
        timescale = source.get('timescale')
        if timescale:
            ms_info['timescale'] = int(timescale)
        segment_duration = source.get('duration')
        if segment_duration:
            ms_info['segment_duration'] = float(segment_duration)

    def extract_Initialization(source):
        initialization = source.find(_add_ns('Initialization'))
        if (initialization is not None):
            ms_info['initialization_url'] = initialization.attrib['sourceURL']
    segment_list = element.find(_add_ns('SegmentList'))
    if (segment_list is not None):
        extract_common(segment_list)
        extract_Initialization(segment_list)
        segment_urls_e = segment_list.findall(_add_ns('SegmentURL'))
        if segment_urls_e:
            ms_info['segment_urls'] = [segment.attrib['media'] for segment in segment_urls_e]
    else:
        segment_template = element.find(_add_ns('SegmentTemplate'))
        if (segment_template is not None):
            extract_common(segment_template)
            media = segment_template.get('media')
            if media:
                ms_info['media'] = media
            initialization = segment_template.get('initialization')
            if initialization:
                ms_info['initialization'] = initialization
            else:
                extract_Initialization(segment_template)
    return ms_info
def extract_multisegment_info(element, ms_parent_info):
    ms_info = ms_parent_info.copy()

    def extract_common(source):
        segment_timeline = source.find(_add_ns('SegmentTimeline'))
        if (segment_timeline is not None):
            s_e = segment_timeline.findall(_add_ns('S'))
            if s_e:
                ms_info['total_number'] = 0
                ms_info['s'] = []
                for s in s_e:
                    r = int(s.get('r', 0))
                    ms_info['total_number'] += (1 + r)
                    ms_info['s'].append({'t': int(s.get('t', 0)), 'd': int(s.attrib['d']), 'r': r})
        start_number = source.get('startNumber')
        if start_number:
            ms_info['start_number'] = int(start_number)
        timescale = source.get('timescale')
        if timescale:
            ms_info['timescale'] = int(timescale)
        segment_duration = source.get('duration')
        if segment_duration:
            ms_info['segment_duration'] = float(segment_duration)

    def extract_Initialization(source):
        initialization = source.find(_add_ns('Initialization'))
        if (initialization is not None):
            ms_info['initialization_url'] = initialization.attrib['sourceURL']
    segment_list = element.find(_add_ns('SegmentList'))
    if (segment_list is not None):
        extract_common(segment_list)
        extract_Initialization(segment_list)
        segment_urls_e = segment_list.findall(_add_ns('SegmentURL'))
        if segment_urls_e:
            ms_info['segment_urls'] = [segment.attrib['media'] for segment in segment_urls_e]
    else:
        segment_template = element.find(_add_ns('SegmentTemplate'))
        if (segment_template is not None):
            extract_common(segment_template)
            media = segment_template.get('media')
            if media:
                ms_info['media'] = media
            initialization = segment_template.get('initialization')
            if initialization:
                ms_info['initialization'] = initialization
            else:
                extract_Initialization(segment_template)
    return ms_info