#!/usr/pkg/bin/python3.13
##
# Last Edited:  2018-02-13 Carlos Alves <carlosalves90@gmail.com>
##

__license__ = 'GPL v3'
__author__ = '2010, Gustavo Azambuja <hola at gazambuja.com>'
'''
180.com.uy
'''

from calibre.web.feeds.news import BasicNewsRecipe


class Noticias(BasicNewsRecipe):
    title = '180.com.uy'
    __author__ = 'Gustavo Azambuja'
    description = 'Noticias de Uruguay'
    language = 'es_UY'
    timefmt = '[%a, %d %b, %Y]'
    use_embedded_content = False
    recursion = 5
    encoding = 'utf-8'
    remove_javascript = True
    no_stylesheets = True

    oldest_article = 2
    max_articles_per_feed = 100
    remove_tags_after = dict(name='article')
    keep_only_tags = [
        dict(name='div', attrs={'class': 'nota'}),
        dict(name='h3',),
        dict(name='h4',),
        dict(name='article',)
    ]
    remove_tags = [
        dict(name='div', attrs={'class': 'items'})
    ]

    remove_attributes = ['width', 'height', 'style', 'font', 'color']

    extra_css = '''
                h1{font-family: Georgia,"Times New Roman",Times,serif}
                h3{font-family: Georgia,"Times New Roman",Times,serif}
                h2{font-family: Georgia,"Times New Roman",Times,serif}
                p{font-family: Verdana,Arial,Helvetica,sans-serif}
                body{font-family: Verdana,Arial,Helvetica,sans-serif}
                img{margin-bottom: 0.4em; display:block;}
                '''

    feeds = [
        (u'Titulares', u'http://www.180.com.uy/feed.php')
    ]

    def get_cover_url(self):
        pass

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