'Return processed and validated server library items list.
Parameters required:    section_type { movie, show, episode, artist }
section_id { unique library key }
Output: array'

def get_library_children_details(self, section_id='', section_type='', list_type='all', count='', rating_key='', label_key='', get_media_info=False):

    if (section_type == 'movie'):
        sort_type = '&type=1'
    elif (section_type == 'show'):
        sort_type = '&type=2'
    elif (section_type == 'season'):
        sort_type = '&type=3'
    elif (section_type == 'episode'):
        sort_type = '&type=4'
    elif (section_type == 'artist'):
        sort_type = '&type=8'
    elif (section_type == 'album'):
        sort_type = '&type=9'
    elif (section_type == 'track'):
        sort_type = '&type=10'
    elif (section_type == 'photo'):
        sort_type = ''
    elif (section_type == 'photoAlbum'):
        sort_type = '&type=14'
    elif (section_type == 'picture'):
        sort_type = '&type=13'
    else:
        sort_type = ''
    if str(section_id).isdigit():
        library_data = self.get_library_list(str(section_id), list_type, count, sort_type, label_key, output_format='xml')
    elif str(rating_key).isdigit():
        library_data = self.get_children_list(str(rating_key), output_format='xml')
    else:
        logger.warn(u'PlexPy    Pmsconnect    ::    get_library_children    called    by    invalid    section_id    or    rating_key    provided.')
        return []
    try:
        xml_head = library_data.getElementsByTagName('MediaContainer')
    except Exception as e:
        logger.warn((u'PlexPy    Pmsconnect    ::    Unable    to    parse    XML    for    get_library_children_details:    %s.' % e))
        return []
    childern_list = []
    for a in xml_head:
        if a.getAttribute('size'):
            if (a.getAttribute('size') == '0'):
                logger.debug(u'PlexPy    Pmsconnect    ::    No    library    data.')
                childern_list = {'library_count': '0', 'childern_list': []}
                return childern_list
        if rating_key:
            library_count = helpers.get_xml_attr(xml_head[0], 'size')
        else:
            library_count = helpers.get_xml_attr(xml_head[0], 'totalSize')
        item_main = []
        if a.getElementsByTagName('Directory'):
            dir_main = a.getElementsByTagName('Directory')
            item_main += [d for d in dir_main if helpers.get_xml_attr(d, 'ratingKey')]
        if a.getElementsByTagName('Video'):
            item_main += a.getElementsByTagName('Video')
        if a.getElementsByTagName('Track'):
            item_main += a.getElementsByTagName('Track')
        if a.getElementsByTagName('Photo'):
            item_main += a.getElementsByTagName('Photo')
        for item in item_main:
            item_info = {'section_id': helpers.get_xml_attr(a, 'librarySectionID'), 'media_type': helpers.get_xml_attr(item, 'type'), 'rating_key': helpers.get_xml_attr(item, 'ratingKey'), 'parent_rating_key': helpers.get_xml_attr(item, 'parentRatingKey'), 'grandparent_rating_key': helpers.get_xml_attr(a, 'grandparentRatingKey'), 'title': helpers.get_xml_attr(item, 'title'), 'parent_title': helpers.get_xml_attr(a, 'parentTitle'), 'grandparent_title': helpers.get_xml_attr(a, 'grandparentTitle'), 'media_index': helpers.get_xml_attr(item, 'index'), 'parent_media_index': helpers.get_xml_attr(a, 'parentIndex'), 'year': helpers.get_xml_attr(item, 'year'), 'thumb': helpers.get_xml_attr(item, 'thumb'), 'parent_thumb': helpers.get_xml_attr(a, 'thumb'), 'grandparent_thumb': helpers.get_xml_attr(a, 'grandparentThumb'), 'added_at': helpers.get_xml_attr(item, 'addedAt')}
            if get_media_info:
                item_media = item.getElementsByTagName('Media')
                for media in item_media:
                    media_info = {'container': helpers.get_xml_attr(media, 'container'), 'bitrate': helpers.get_xml_attr(media, 'bitrate'), 'video_codec': helpers.get_xml_attr(media, 'videoCodec'), 'video_resolution': helpers.get_xml_attr(media, 'videoResolution'), 'video_framerate': helpers.get_xml_attr(media, 'videoFrameRate'), 'audio_codec': helpers.get_xml_attr(media, 'audioCodec'), 'audio_channels': helpers.get_xml_attr(media, 'audioChannels'), 'file': helpers.get_xml_attr(media.getElementsByTagName('Part')[0], 'file'), 'file_size': helpers.get_xml_attr(media.getElementsByTagName('Part')[0], 'size')}
                    item_info.update(media_info)
            childern_list.append(item_info)
    output = {'library_count': library_count, 'childern_list': childern_list}
    return output
