#!/usr/bin/env  python
__license__   = 'GPL v3'
__author__    = 'Jordi Balcells, based on an earlier version by Lorenzo Vigentini & Kovid Goyal'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
description   = 'Main daily newspaper from Spain - v1.04 (19, October 2010)'
__docformat__ = 'restructuredtext en'

'''
elpais.es
'''

from time import strftime

from calibre.web.feeds.news import BasicNewsRecipe

class ElPais(BasicNewsRecipe):
    __author__        = 'Kovid Goyal & Lorenzo Vigentini & Jordi Balcells'
    description   = 'Main daily newspaper from Spain'

    title          = u'El Pais'
    publisher      = u'Ediciones El Pa\xeds SL'
    category       = 'News, politics, culture, economy, general interest'

    language       = 'es'
    timefmt        = '[%a, %d %b, %Y]'

    oldest_article = 2
    max_articles_per_feed = 15

    use_embedded_content  = False
    recursion             = 5

    remove_javascript = True
    no_stylesheets = True

    keep_only_tags = [ dict(name='div', attrs={'class':['cabecera_noticia_reportaje estirar','cabecera_noticia_opinion estirar','cabecera_noticia estirar','contenido_noticia','cuerpo_noticia','caja_despiece']})]

    extra_css             = ' p{text-align: justify; font-size: 100%} body{ text-align: left; font-family: serif; font-size: 100% } h1{ font-family: sans-serif; font-size:200%; font-weight: bolder; text-align: justify; } h2{ font-family: sans-serif; font-size:150%; font-weight: 500; text-align: justify } h3{ font-family: sans-serif; font-size:125%; font-weight: 500; text-align: justify } img{margin-bottom: 0.4em} '

    remove_tags    = [
                        dict(name='div', attrs={'class':['zona_superior','pie_enlaces_inferiores','contorno_f','ampliar']}),
                        dict(name='div', attrs={'class':['limpiar','mod_apoyo','borde_sup','votos estirar','info_complementa','info_relacionada','buscador_m','nav_ant_sig']}),
                        dict(name='div', attrs={'id':['suscribirse suscrito','google_noticia','utilidades','coment','foros_not','pie','lomas','calendar']}),
                        dict(name='p', attrs={'class':'nav_meses'}),
                        dict(attrs={'class':['enlaces_m','miniaturas_m','nav_miniaturas_m']})
                    ]

    feeds          = [
                        (u'Titulares de portada', u'http://www.elpais.com/rss/feed.html?feedId=1022'),
                        (u'Internacional', u'http://www.elpais.com/rss/feed.html?feedId=1001'),
                        (u'Espa\xf1a', u'http://www.elpais.com/rss/feed.html?feedId=1002'),
                        (u'Deportes', u'http://www.elpais.com/rss/feed.html?feedId=1007'),
                        (u'Econom\xeda', u'http://www.elpais.com/rss/feed.html?feedId=1006'),
                        (u'Pol\xedtica', u'http://www.elpais.com/rss/feed.html?feedId=17073'),
                        (u'Tecnolog\xeda', u'http://www.elpais.com/rss/feed.html?feedId=1005'),
                        (u'Cultura', u'http://www.elpais.com/rss/feed.html?feedId=1008'),
                        (u'Gente', u'http://www.elpais.com/rss/feed.html?feedId=1009'),
                        (u'Sociedad', u'http://www.elpais.com/rss/feed.html?feedId=1004'),
                        (u'Opini\xf3n', u'http://www.elpais.com/rss/feed.html?feedId=1003'),
                        (u'Ciencia', u'http://www.elpais.com/rss/feed.html?feedId=17068'),
                        (u'Justicia y leyes', u'http://www.elpais.com/rss/feed.html?feedId=17069'),
                        (u'Medio ambiente', u'http://www.elpais.com/rss/feed.html?feedId=17071'),
                        (u'Vi\xf1etas', u'http://www.elpais.com/rss/feed.html?feedId=17058')
                        ]

    def get_cover_url(self):
        return 'http://img5.kiosko.net/' + strftime("%Y/%m/%d") + '/es/elpais.750.jpg'

