
__license__ = 'GPL v3'
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
'''
www.ionline.pt
'''

from calibre.web.feeds.news import BasicNewsRecipe


class IOnline_pt(BasicNewsRecipe):
    title = 'ionline - Portugal'
    __author__ = 'Darko Miletic'
    description = 'News from Portugal'
    publisher = 'ionline.pt'
    oldest_article = 2
    max_articles_per_feed = 100
    no_stylesheets = True
    encoding = 'utf-8'
    use_embedded_content = False
    language = 'pt'
    extra_css = ' .publish{font-style: italic; line-height: 1.2em; border-bottom: 1px dotted; padding: 5px 0} .entity{line-height: 1.2em} .overview{line-height:1.2em} '  # noqa

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

    keep_only_tags = [
        dict(name=['h5', 'h1']), dict(name='div', attrs={
            'class': ['publish', 'overview', 'entity']})
    ]

    remove_tags = [
        dict(name=['object', 'embed', 'iframe'])
    ]

    feeds = [

    (u'Portugal', u'http://www.ionline.pt/rss/portugal.xml'),
    (u'Mundo', u'http://www.ionline.pt/rss/mundo.xml'),
    (u'Dinheiro', u'http://www.ionline.pt/rss/dinheiro.xml'),
    (u'Desporto', u'http://www.ionline.pt/rss/desporto.xml'),
    (u'Boa Vida', u'http://www.ionline.pt/rss/boavida.xml'),
    (u'iReporter', u'http://www.ionline.pt/rss/ireporter.xml'),
    (u'iBloges', u'http://www.ionline.pt/rss/iblogues.xml'),
    (u'Desporto', u'http://www.ionline.pt/rss/desporto.xml')
    ]

    def print_version(self, url):
        rest = url.rpartition('/')[2]
        lmain = rest.partition('-')[0]
        lurl = u'http://www.ionline.pt/interior/index.php?p=news-print&idNota=' + lmain
        return lurl
