'Return processed list of search results.
Output: array'

def get_search_results(self, query=''):

    search_results = self.get_search(query=query, output_format='xml')
    search_results_tracks = self.get_search(query=query, track='&type=10', output_format='xml')
    xml_head = []
    try:
        try:
            xml_head += search_results.getElementsByTagName('MediaContainer')
        except:
            pass
        try:
            xml_head += search_results_tracks.getElementsByTagName('MediaContainer')
        except:
            pass
    except Exception as e:
        logger.warn((u'PlexPy    Pmsconnect    ::    Unable    to    parse    XML    for    get_search_result_details:    %s.' % e))
        return []
    search_results_count = 0
    search_results_list = {'movie': [], 'show': [], 'season': [], 'episode': [], 'artist': [], 'album': [], 'track': []}
    totalSize = 0
    for a in xml_head:
        if a.getAttribute('size'):
            totalSize += int(a.getAttribute('size'))
    if (totalSize == 0):
        logger.debug(u'PlexPy    Pmsconnect    ::    No    search    results.')
        search_results_list = {'results_count': search_results_count, 'results_list': []}
        return search_results_list
    for a in xml_head:
        if a.getElementsByTagName('Video'):
            result_data = a.getElementsByTagName('Video')
            for result in result_data:
                rating_key = helpers.get_xml_attr(result, 'ratingKey')
                metadata = self.get_metadata_details(rating_key=rating_key)
                if (metadata['metadata']['media_type'] == 'movie'):
                    search_results_list['movie'].append(metadata['metadata'])
                elif (metadata['metadata']['media_type'] == 'episode'):
                    search_results_list['episode'].append(metadata['metadata'])
                search_results_count += 1
        if a.getElementsByTagName('Directory'):
            result_data = a.getElementsByTagName('Directory')
            for result in result_data:
                rating_key = helpers.get_xml_attr(result, 'ratingKey')
                metadata = self.get_metadata_details(rating_key=rating_key)
                if (metadata['metadata']['media_type'] == 'show'):
                    search_results_list['show'].append(metadata['metadata'])
                    show_seasons = self.get_item_children(rating_key=metadata['metadata']['rating_key'])
                    if (show_seasons['children_count'] != '0'):
                        for season in show_seasons['children_list']:
                            if season['rating_key']:
                                rating_key = season['rating_key']
                                metadata = self.get_metadata_details(rating_key=rating_key)
                                search_results_list['season'].append(metadata['metadata'])
                                search_results_count += 1
                elif (metadata['metadata']['media_type'] == 'artist'):
                    search_results_list['artist'].append(metadata['metadata'])
                elif (metadata['metadata']['media_type'] == 'album'):
                    search_results_list['album'].append(metadata['metadata'])
                search_results_count += 1
        if a.getElementsByTagName('Track'):
            result_data = a.getElementsByTagName('Track')
            for result in result_data:
                rating_key = helpers.get_xml_attr(result, 'ratingKey')
                metadata = self.get_metadata_details(rating_key=rating_key)
                search_results_list['track'].append(metadata['metadata'])
                search_results_count += 1
    output = {'results_count': search_results_count, 'results_list': {k: v for (k, v) in search_results_list.iteritems()}}
    return output
