# -*- coding: utf-8 -*-
__license__   = 'GPL v3'
__author__    = 'Luis Hernandez'
__copyright__ = 'Luis Hernandez<tolyluis@gmail.com>'
__version__     = 'v1.0'
__date__        = '01 Feb 2011'

'''
http://www.promecal.es/
'''
from calibre.web.feeds.news import BasicNewsRecipe

class AdvancedUserRecipe1294946868(BasicNewsRecipe):

    title             = u'La Tribuna de'
    publisher      = u'Grupo PROMECAL'

    __author__  = 'Luis Hernández'
    description   = 'Varios diarios locales del grupo PROMECAL'

    oldest_article = 3
    max_articles_per_feed = 50

    remove_javascript = True
    no_stylesheets        = True
    use_embedded_content  = False

    encoding              = 'utf-8'
    language              = 'es'
    timefmt        = '[%a, %d %b, %Y]'

    keep_only_tags     = [
                                   dict(name='div', attrs={'id':['articulo']})
                                  ,dict(name='div', attrs={'class':['foto']})
                                  ,dict(name='p', attrs={'id':['texto']})
                                ]

    remove_tags_before = dict(name='div' , attrs={'class':['comparte']})
    remove_tags_after  = dict(name='div' , attrs={'id':['relacionadas']})

    remove_tags  = [
                              dict(name='div', attrs={'id':['relacionadas']})
                             ,dict(name='h3')
                             ,dict(name='h5')
                          ]

    extra_css             = """
                               p{text-align: justify; font-size: 100%}
                               body{text-align: left; font-family: serif; font-size: 100%}
                               h1{font-family: sans; font-size:150%; font-weight: bold; text-align: justify;}
                               h2{font-family: sans-serif; font-size:85%; font-style: italic; text-align: justify;}
                               h4{font-family: sans; font-size:75%; font-weight: bold; text-align: center;}
                               img{margin-bottom: 0.4em}
                                """

    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


    feeds          = [
           (u'Albacete', u'http://www.latribunadealbacete.es/rss.html')
          ,(u'Avila', u'http://www.diariodeavila.es/rss.html')
          ,(u'Burgos', u'http://www.diariodeburgos.es/rss.html')
          ,(u'Ciudad Real', u'http://www.latribunadeciudadreal.es/rss.html')
          ,(u'Palencia', u'http://www.diariopalentino.es/rss.html')
          ,(u'Puertollano', u'http://www.latribunadepuertollano.es/rss.html')
          ,(u'Talavera de la Reina', u'http://www.latribunadetalavera.es/rss.html')
          ,(u'Toledo', u'http://www.latribunadetoledo.es/rss.html')
          ,(u'Valladolid', u'http://www.eldiadevalladolid.com/rss.html')
                       ]
