#!/usr/bin/env  python

__license__   = 'GPL v3'
__author__ = '2013, Carlos Alves <carlosalves90@gmail.com>'
'''
unoticias.com.uy
'''

from calibre.web.feeds.news import BasicNewsRecipe

class General(BasicNewsRecipe):
    title                 = 'UNoticias'
    __author__            = 'Carlos Alves'
    description           = 'Noticias Uruguay'
    tags = 'news, sports, politics'
    language       = 'es_UY'
    timefmt        = '[%a, %d %b, %Y]'
    use_embedded_content  = False
    recursion             = 5
    encoding = 'ISO-8859-1'
    remove_javascript = True
    no_stylesheets = True

    oldest_article        = 2
    max_articles_per_feed = 100
    keep_only_tags = [
             dict(name='h1', attrs={'class':'nombre'}),
             dict(name='h2', attrs={'class':'copete t20'}),
             dict(name='div', attrs={'class':'desc'})
             ]

    remove_tags = [
             dict(name='div', attrs={'class':['br', 'hr', 'titlebar', 'navigation']}),
             dict(name='div', attrs={'id':'comment'}),
             dict(name=['object','link'])
                  ]

    extra_css = '''
                h1{font-family:Geneva, Arial, Helvetica, sans-serif;color:#154B7A;}
                h3{font-size: 14px;color:#999999; font-family:Geneva, Arial, Helvetica, sans-serif;font-weight: bold;}
                h2{color:#666666; font-family:Geneva, Arial, Helvetica, sans-serif;font-size:small;}
                p {font-family:Arial,Helvetica,sans-serif;}
                '''
    feeds = [
           (u'Nacionales', u'http://www.unoticias.com.uy/RSS/nacionales.xml'),
           (u'Deportes', u'http://www.unoticias.com.uy/RSS/deportes.xml'),
           (u'Sociedad', u'http://www.unoticias.com.uy/RSS/Sociedad.xml')
        ]

    def get_cover_url(self):
        return 'http://www.unoticias.com.uy/artworks/logos/logo_small.gif'

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