__license__   = 'GPL v3'
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
'''
www.lostiempos.com
'''

from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe

class LosTiempos_Bol(BasicNewsRecipe):
    title                 = 'Los Tiempos - Bolivia'
    __author__            = 'Darko Miletic'
    description           = 'El periódico de mayor circulación en la ciudad de Cochabamba, Bolivia'
    publisher             = 'Los Tiempos'
    category              = 'news, politics, Bolivia'
    oldest_article        = 1
    max_articles_per_feed = 200
    no_stylesheets        = True
    encoding              = 'cp1252'
    use_embedded_content  = False
    language              = 'es'
    publication_type      = 'newspaper'
    delay                 = 1
    remove_empty_feeds    = True
    cover_url             = strftime('http://www.lostiempos.com/media_recortes/%Y/%m/%d/portada_md_1.jpg')
    masthead_url          = 'http://www.lostiempos.com/img_stat/logo_tiempos_sin_beta.jpg'
    extra_css             = """ body{font-family: Arial,Helvetica,sans-serif }
                                img{margin-bottom: 0.4em}
                                h1,.hora,.breadcum,.pie_foto{font-family: Georgia,"Times New Roman",Times,serif}
                                .hora,.breadcum,.pie_foto{font-size: small}
                                .en_gris,.pie_foto{color: #666666}
                                """

    conversion_options = {
                          'comment'   : description
                        , 'tags'      : category
                        , 'publisher' : publisher
                        , 'language'  : language
                        }

    keep_only_tags    = [dict(name='div', attrs={'id':'articulo'})]
    remove_tags       = [
                          dict(name=['meta','link','form','iframe','embed','object','hr'])
                         ,dict(attrs={'class':['caja_fonts sin_border_bot','pub']})
                        ]
    remove_attributes = ['width','height']

    feeds = [
              (u'Nacional'       , u'http://www.lostiempos.com/rss/lostiempos-nacional.xml'       )
             ,(u'Local'          , u'http://www.lostiempos.com/rss/lostiempos-local.xml'          )
             ,(u'Deportes'       , u'http://www.lostiempos.com/rss/lostiempos-deportes.xml'       )
             ,(u'Economía'       , u'http://www.lostiempos.com/rss/lostiempos-economia.xml'       )
             ,(u'Internacional'  , u'http://www.lostiempos.com/rss/lostiempos-internacional.xml'  )
             ,(u'Vida y Futuro'  , u'http://www.lostiempos.com/rss/lostiempos-vida-y-futuro.xml'  )
             ,(u'Tragaluz'       , u'http://www.lostiempos.com/rss/lostiempos-tragaluz.xml'       )
             ,(u'Opiniones'      , u'http://www.lostiempos.com/rss/lostiempos-opiniones.xml'      )
            ]

    def preprocess_html(self, soup):
        for item in soup.findAll(style=True):
            del item['style']
        return soup

