'Return processed and validated library statistics.
Output: array'

def get_library_details(self):

    server_libraries = self.get_server_children()
    server_library_stats = []
    if (server_libraries and (server_libraries['libraries_count'] != '0')):
        libraries_list = server_libraries['libraries_list']
        for library in libraries_list:
            section_type = library['section_type']
            section_id = library['section_id']
            children_list = self.get_library_children_details(section_id=section_id, section_type=section_type, count='1')
            if children_list:
                library_stats = {'section_id': section_id, 'section_name': library['section_name'], 'section_type': section_type, 'thumb': library['thumb'], 'art': library['art'], 'count': children_list['library_count']}
                if (section_type == 'show'):
                    parent_list = self.get_library_children_details(section_id=section_id, section_type='season', count='1')
                    if parent_list:
                        parent_stats = {'parent_count': parent_list['library_count']}
                        library_stats.update(parent_stats)
                    child_list = self.get_library_children_details(section_id=section_id, section_type='episode', count='1')
                    if child_list:
                        child_stats = {'child_count': child_list['library_count']}
                        library_stats.update(child_stats)
                if (section_type == 'artist'):
                    parent_list = self.get_library_children_details(section_id=section_id, section_type='album', count='1')
                    if parent_list:
                        parent_stats = {'parent_count': parent_list['library_count']}
                        library_stats.update(parent_stats)
                    child_list = self.get_library_children_details(section_id=section_id, section_type='track', count='1')
                    if child_list:
                        child_stats = {'child_count': child_list['library_count']}
                        library_stats.update(child_stats)
                if (section_type == 'photo'):
                    parent_list = self.get_library_children_details(section_id=section_id, section_type='photoAlbum', count='1')
                    if parent_list:
                        parent_stats = {'parent_count': parent_list['library_count']}
                        library_stats.update(parent_stats)
                    child_list = self.get_library_children_details(section_id=section_id, section_type='picture', count='1')
                    if child_list:
                        child_stats = {'child_count': child_list['library_count']}
                        library_stats.update(child_stats)
                server_library_stats.append(library_stats)
    return server_library_stats
