'Return array of movie details (dict)'

def search(self, name):

    log.debug((u'Searching:    %s' % name))
    url = u'http://www.imdb.com/find'
    params = {u'q': name, u's': u'tt'}
    log.debug((u'Search    query:    %s' % repr(url)))
    page = requests.get(url, params=params)
    actual_url = page.url
    movies = []
    soup = get_soup(page.text)
    re_m = re.match(u'.*\\.imdb\\.com/title/tt\\d+/', actual_url)
    if re_m:
        div = soup.find(u'div', {u'class': u'title_wrapper'})
        title_wrapper = div.find(u'h1', {u'itemprop': u'name'})
        title = u''.join((text for text in title_wrapper.find_all(text=True) if (text.parent.name not in [u'span', u'a'])))
        title = title.strip()
        year = div.find(u'a').text
        actual_url = re_m.group(0)
        log.debug((u'Perfect    hit.    Search    got    redirected    to    %s' % actual_url))
        movie = {}
        movie[u'match'] = 1.0
        movie[u'name'] = title
        movie[u'imdb_id'] = extract_id(actual_url)
        movie[u'url'] = make_url(movie[u'imdb_id'])
        movie[u'year'] = year
        movies.append(movie)
        return movies
    section_table = soup.find(u'table', u'findList')
    if (not section_table):
        log.debug(u'results    table    not    found')
        return
    rows = section_table.find_all(u'tr')
    if (not rows):
        log.debug(u'Titles    section    does    not    have    links')
    for (count, row) in enumerate(rows):
        if (count > self.max_results):
            break
        result_text = row.find(u'td', u'result_text')
        movie = {}
        additional = re.findall(u'\\((.*?)\\)', result_text.text)
        if (len(additional) > 0):
            if re.match(u'^\\d{4}$', additional[(-1)]):
                movie[u'year'] = additional[(-1)]
            elif (len(additional) > 1):
                movie[u'year'] = additional[(-2)]
                if (additional[(-1)] not in [u'TV    Movie', u'Video']):
                    log.debug(u'skipping    %s', result_text.text)
                    continue
        primary_photo = row.find(u'td', u'primary_photo')
        movie[u'thumbnail'] = primary_photo.find(u'a').find(u'img').get(u'src')
        link = result_text.find_next(u'a')
        movie[u'name'] = link.text
        movie[u'imdb_id'] = extract_id(link.get(u'href'))
        movie[u'url'] = make_url(movie[u'imdb_id'])
        log.debug((u'processing    name:    %s    url:    %s' % (movie[u'name'], movie[u'url'])))
        seq = difflib.SequenceMatcher((lambda x: (x == u'    ')), movie[u'name'].title(), name.title())
        ratio = seq.ratio()
        for aka in link.parent.find_all(u'i'):
            aka = aka.next.string
            match = re.search(u'".*"', aka)
            if (not match):
                log.debug((u'aka    `%s`    is    invalid' % aka))
                continue
            aka = match.group(0).replace(u'"', u'')
            log.trace((u'processing    aka    %s' % aka))
            seq = difflib.SequenceMatcher((lambda x: (x == u'    ')), aka.title(), name.title())
            aka_ratio = seq.ratio()
            if (aka_ratio > ratio):
                ratio = (aka_ratio * self.aka_weight)
                log.debug((u'-    aka    `%s`    matches    better    to    `%s`    ratio    %s    (weighted    to    %s)' % (aka, name, aka_ratio, ratio)))
        position_ratio = (((self.first_weight - 1) / (count + 1)) + 1)
        log.debug((u'-    prioritizing    based    on    position    %s    `%s`:    %s' % (count, movie[u'url'], position_ratio)))
        ratio *= position_ratio
        movie[u'match'] = ratio
        movies.append(movie)
    movies.sort(key=(lambda x: x[u'match']), reverse=True)
    return movies
