#!/usr/bin/env python

__license__ = 'GPL v3'
__copyright__ = '2008-2011, Lionel Bergeret <lbergeret at gmail.com>'
'''
lavenir.net
'''

from calibre.web.feeds.news import BasicNewsRecipe


class LAvenir(BasicNewsRecipe):
    title = u'L\'Avenir'
    __author__ = u'Lionel Bergeret'
    description = u'News from Belgium in French'
    publisher = u'lavenir.net'
    category = 'news, Belgium'
    oldest_article = 3
    language = 'fr'

    max_articles_per_feed = 20
    no_stylesheets = True
    use_embedded_content = False
    timefmt = ' [%d %b %Y]'

    keep_only_tags = [
        dict(name='div', attrs={'class': 'photo'}), dict(name='p', attrs={
            'class': 'intro'}), dict(name='div', attrs={'class': 'article-body'})
    ]

    feeds = [

    (u'Belgique', u'http://www.lavenir.net/rss.aspx?foto=1&intro=1&section=info&info=df156511-c24f-4f21-81c3-a5d439a9cf4b'),
    (u'Monde', u'http://www.lavenir.net/rss.aspx?foto=1&intro=1&section=info&info=1642237c-66b9-4e8a-a8c1-288d61fefe7e'),
    (u'Societe', u'http://www.lavenir.net/rss.aspx?foto=1&intro=1&section=info&info=12e1a2f4-7e03-4cf1-afec-016869072317')
    ]

    def preprocess_html(self, soup):
        for alink in soup.findAll('a'):
            if alink.string is not None:
                tstr = alink.string
                alink.replaceWith(tstr)
        return soup

    def get_cover_url(self):
        cover_url = 'http://www.lavenir.net/extra/Static/journal/Pdf/1/UNE_Nationale.PDF'
        return cover_url
