#!/usr/bin/env python
# -*- mode: python -*-
# -*- coding: utf-8 -*-

__license__ = 'GPL v3'
__copyright__ = '2012-2016, Darko Miletic <darko.miletic at gmail.com>'
'''
www.telam.com.ar
'''

from calibre.web.feeds.news import BasicNewsRecipe


class Telam(BasicNewsRecipe):
    title = 'Telam'
    __author__ = 'Darko Miletic'
    description = 'AGENCIA DE NOTICIAS DE LA REPUBLICA ARGENTINA'
    publisher = 'Telam S.E.'
    category = 'news, politics, Argentina'
    oldest_article = 2
    max_articles_per_feed = 200
    no_stylesheets = True
    encoding = 'windows-1252'
    use_embedded_content = False
    language = 'es_AR'
    remove_empty_feeds = True
    auto_cleanup = True
    publication_type = 'newsportal'
    PREFIX = 'http://www.telam.com.ar'
    masthead_url = 'http://www.telam.com.ar/assets/img/logo.svg'
    extra_css             = """
                               body{font-family: Arial,Helvetica,sans-serif }
                               img{margin-bottom: 0.4em; display:block}
                            """

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

    feeds = [
                (u'Ultimas noticias', u'http://www.telam.com.ar/rss2/ultimasnoticias.xml'),
                (u'Politica', u'http://www.telam.com.ar/rss2/politica.xml'),
                (u'Economia', u'http://www.telam.com.ar/rss2/economia.xml'),
                (u'Sociedad', u'http://www.telam.com.ar/rss2/sociedad.xml'),
                (u'Policiales', u'http://www.telam.com.ar/rss2/policiales.xml'),
                (u'Internacionales', u'http://www.telam.com.ar/rss2/internacional.xml'),
                (u'Espectaculos', u'http://www.telam.com.ar/rss2/espectaculos.xml'),
                (u'Cultura', u'http://www.telam.com.ar/rss2/cultura.xml'),
                (u'Deportes', u'http://www.telam.com.ar/rss2/deportes.xml'),
                (u'Educacion', u'http://www.telam.com.ar/rss2/educacion.xml')
    ]

    def get_article_url(self, article):
        url = BasicNewsRecipe.get_article_url(self, article)
        if url.startswith('/'):
            return self.PREFIX + url
        return url
