'Search for name from fuzer.'

@plugin.internet(log)
def search(self, task, entry, config=None):

    self.rss_key = config[u'rss_key']
    username = config[u'username']
    password = hashlib.md5(config[u'password'].encode(u'utf-8')).hexdigest()
    data = {u'cookieuser': u'1', u'do': u'login', u's': u'', u'securitytoken': u'guest', u'vb_login_username': username, u'vb_login_password': u'', u'vb_login_md5password': password, u'vb_login_md5password_utf': password}
    try:
        login = requests.post(u'https://www.fuzer.me/login.php?do=login', data=data)
    except RequestException as e:
        raise PluginError((u'Could    not    connect    to    fuzer:    %s' % str(e)))
    login_check_phrases = [u'\u05d4\u05d4\u05ea\u05d7\u05d1\u05e8\u05d5\u05ea    \u05e0\u05db\u05e9\u05dc\u05d4', u'banned']
    if any(((phrase in login.text) for phrase in login_check_phrases)):
        raise PluginError(u'Login    to    Fuzer    failed,    check    credentials')
    self.user_id = requests.cookies.get(u'fzr2userid')
    category = config.get(u'category', [0])
    if (not isinstance(category, list)):
        category = [category]
    categories = [(c if isinstance(c, int) else CATEGORIES[c]) for c in category]
    c_list = []
    for c in categories:
        c_list.append(u'c{}={}'.format(quote_plus(u'[]'), c))
    entries = []
    if entry.get(u'imdb_id'):
        log.debug(u'imdb_id    {}    detected,    using    in    search.'.format(entry[u'imdb_id']))
        soup = self.get_fuzer_soup(entry[u'imdb_id'], c_list)
        entries = self.extract_entry_from_soup(soup)
        if entries:
            for e in list(entries):
                e[u'imdb_id'] = entry.get(u'imdb_id')
    else:
        for search_string in entry.get(u'search_strings', [entry[u'title']]):
            query = normalize_unicode(search_string).replace(u':', u'')
            text = quote_plus(query.encode(u'windows-1255'))
            soup = self.get_fuzer_soup(text, c_list)
            entries += self.extract_entry_from_soup(soup)
    return (sorted(entries, reverse=True, key=(lambda x: x.get(u'search_sort'))) if entries else [])
