#!/usr/bin/env python
# vim:fileencoding=utf-8
__license__ = 'GPL v3'
__author__ = 'Ricardo Jurado'
__copyright__ = 'Ricardo Jurado'
__version__ = 'v0.4'
__date__ = '11 February 2011'

'''
http://www.abc.es/
'''

from calibre.web.feeds.news import BasicNewsRecipe


class AdvancedUserRecipe1296604369(BasicNewsRecipe):
    title = 'ABC.es'
    masthead_url = 'http://www.abc.es/img/logo-abc.gif'
    cover_url = 'http://www.abc.es/img/logo-abc.gif'
    publisher = 'Grupo VOCENTO'

    __author__ = 'Ricardo Jurado'
    description = 'Noticias de Spain y el mundo'
    category = 'News,Spain,National,International,Economy'
    oldest_article = 2
    max_articles_per_feed = 25

    no_stylesheets = True
    use_embedded_content = False
    encoding = 'ISO-8859-1'
    auto_cleanup = True
    remove_javascript = True
    language = 'es'

    recipe_specific_options = {
        'days': {
            'short': 'Oldest article to download from this news source. In days ',
            'long': 'For example, 0.5, gives you articles from the past 12 hours',
            'default': str(oldest_article),
        }
    }

    def __init__(self, *args, **kwargs):
        BasicNewsRecipe.__init__(self, *args, **kwargs)
        d = self.recipe_specific_options.get('days')
        if d and isinstance(d, str):
            self.oldest_article = float(d)

    extra_css = '''
                               p{text-align: justify; font-size: 100%}
                               body{ text-align: left; font-size:100% }
                               h3{font-family: sans-serif; font-size:120%; font-weight:bold; text-align: justify; }
                               h2{font-family: sans-serif; font-size:100%; font-weight:bold; text-align: justify; }
                               h1{font-family: sans-serif; font-size:150%; font-weight:bold; text-align: justify; }
                                 '''

    feeds = [
        ('PORTADA', 'http://www.abc.es/rss/feeds/abcPortada.xml'),
        ('ULTIMAS', 'http://www.abc.es/rss/feeds/abc_ultima.xml'),
        ('NACIONAL', 'http://www.abc.es/rss/feeds/abc_EspanaEspana.xml'),
        ('INTERNACIONAL', 'http://www.abc.es/rss/feeds/abc_Internacional.xml'),
        ('OPINION', 'http://www.abc.es/rss/feeds/abc_opinioncompleto.xml'),
        ('BLOGS ABC', 'http://www.abc.es/rss/feeds/blogs-abc.xml'),
        ('ECONOMIA', 'http://www.abc.es/rss/feeds/abc_Economia.xml'),
        ('CIENCIA Y TECNOLOGIA', 'http://www.abc.es/rss/feeds/abc_Ciencia_Tecnologia.xml'),
        ('CULTURA', 'http://www.abc.es/rss/feeds/abc_Cultura.xml'),
        ('LIBROS', 'http://www.abc.es/rss/feeds/abc_Libros.xml'),
        ('MEDIOS Y REDES', 'http://www.abc.es/rss/feeds/ABC_Medios_Redes.xml'),
        ('EVASION', 'http://www.abc.es/rss/feeds/abc_evasion.xml'),
        ('ESPECTACULOS', 'http://www.abc.es/rss/feeds/abc_Espectaculos.xml'),
        ('GENTE', 'http://www.abc.es/rss/feeds/abc_Gente.xml'),
        ('DEPORTES', 'http://www.abc.es/rss/feeds/abc_Deportes.xml'),
    ]
