'CPASBIEN search plugin
Config example:
tv_search_cpasbien:
discover:
what:
- trakt_list:
username: xxxxxxx
api_key: xxxxxxx
series: watchlist
from:
- cpasbien:
category: "series-vostfr"
interval: 1 day
ignore_estimations: yes
Category is ONE of:
all
films
series
musique
films-french
1080p
720p
series-francaise
films-dvdrip
films-vostfr
series-vostfr
ebook'

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

    base_url = u'http://www.cpasbien.io'
    entries = set()
    for search_string in entry.get(u'search_strings', [entry[u'title']]):
        search_string = search_string.replace(u'    ', u'-').lower()
        search_string = search_string.replace(u'(', u'')
        search_string = search_string.replace(u')', u'')
        query = normalize_unicode(search_string)
        query_url_fragment = quote_plus(query.encode(u'utf-8'))
        if (config[u'category'] == u'all'):
            str_url = (base_url, u'recherche', query_url_fragment)
            url = u'/'.join(str_url)
        else:
            category_url_fragment = (u'%s' % config[u'category'])
            str_url = (base_url, u'recherche', category_url_fragment, query_url_fragment)
            url = u'/'.join(str_url)
        log.debug(((u'search    url:    %s' % url) + u'.html'))
        f = task.requests.get((url + u'.html')).content
        soup = get_soup(f)
        if soup.findAll(text=re.compile(u'    0    torrents')):
            log.debug(u'search    returned    no    results')
        else:
            nextpage = 0
            while (nextpage >= 0):
                if (nextpage > 0):
                    newurl = ((url + u'/page-') + str(nextpage))
                    log.debug((u'----->    NEXT    PAGE    :    %s' % newurl))
                    f1 = task.requests.get(newurl).content
                    soup = get_soup(f1)
                for result in soup.findAll(u'div', attrs={u'class': re.compile(u'ligne')}):
                    entry = Entry()
                    link = result.find(u'a', attrs={u'href': re.compile(u'dl-torrent')})
                    entry[u'title'] = link.contents[0]
                    page_link = link.get(u'href')
                    link_rewrite = page_link.split(u'/')
                    endlink = link_rewrite[(-1)]
                    str_url = (base_url, u'/telechargement/', endlink[:(-5)], u'.torrent')
                    entry[u'url'] = u''.join(str_url)
                    log.debug((u'Title:    %s    |    DL    LINK:    %s' % (entry[u'title'], entry[u'url'])))
                    entry[u'torrent_seeds'] = int(result.find(u'span', attrs={u'class': re.compile(u'seed')}).text)
                    entry[u'torrent_leeches'] = int(result.find(u'div', attrs={u'class': re.compile(u'down')}).text)
                    size = result.find(u'div', attrs={u'class': re.compile(u'poid')}).text
                    entry[u'content_size'] = parse_filesize(size, si=False)
                    if (entry[u'torrent_seeds'] > 0):
                        entries.add(entry)
                    else:
                        log.debug(u'0    SEED,    not    adding    entry')
                if soup.find(text=re.compile(u'Suiv')):
                    nextpage += 1
                else:
                    nextpage = (-1)
    return entries
