#!/usr/bin/env  python2
__license__ = 'GPL v3'
__author__ = 'Lorenzo Vigentini'
__copyright__ = '2009, Lorenzo Vigentini <l.vigentini at gmail.com>'
__version__ = 'v1.01'
__date__ = '30, January 2010'
__description__ = 'Sport daily news from Italy'

'''www.tuttosport.com'''

from calibre.web.feeds.news import BasicNewsRecipe


class tuttosport(BasicNewsRecipe):
    author = 'Lorenzo Vigentini'
    description = 'Sport daily news from Italy'

    cover_url = 'http://www.tuttosport.com/res/imgs/logo_TuttoSport.png'
    title = 'Tuttosport'
    publisher = 'Nuova Editoriale Sportiva S.r.l'
    category = 'Sport News'

    language = 'it'
    timefmt = '[%a, %d %b, %Y]'

    oldest_article = 2
    max_articles_per_feed = 20
    use_embedded_content = False
    recursion = 10

    remove_javascript = True
    no_stylesheets = True

    def print_version(self, url):
        segments = url.split('/')
        printURL = '/'.join(segments[0:10]) + '?print'
        return printURL

    keep_only_tags = [
        dict(name='h2', attrs={'class': 'tit_Article'}),
        dict(name='div', attrs={
             'class': ['box_Img img_L ', 'txt_ArticleAbstract', 'txt_Article txtBox_cms']})
    ]

    feeds = [
        (u'Primo piano', u'http://www.tuttosport.com/rss/primo_piano.xml'),
        (u'Cronanca', u'http://www.tuttosport.com/rss/Cronaca-205.xml'),
        (u'Lettere al direttore',
         u'http://blog.tuttosport.com/direttore/feed'),
        (u'Calcio', u'http://www.tuttosport.com/rss/Calcio-3.xml'),
        (u'Speciale Derby',
         u'http://www.tuttosport.com/rss/Speciale-derby-310.xml'),
        (u'Formula 1', u'hhttp://www.tuttosport.com/rss/Formula-1-7.xml'),
        (u'Moto', u'hhttp://www.tuttosport.com/rss/Moto-8.xml'),
        (u'Basket', u'http://www.tuttosport.com/rss/Basket-9.xml'),
        (u'Altri Sport', u'http://www.tuttosport.com/rss/Altri-Sport-2.xml'),
        (u'Tuttosport League',
         u'http://www.tuttosport.com/rss/Tuttosport-League-245.xml'),
        (u'Scommesse', u'http://www.tuttosport.com/rss/Scommesse-286.xml')
    ]

    extra_css = '''
                body {font-family: Arial, Verdana, sans-serif; margin-bottom: 3em;}
                h2.tit_Article {color:#9C3A0B;margin: 15px 8px 0; margin-bottom: 1px; border-bottom: 3px solid;}
                .txt_ArticleAbstract {color:#4080AE;clear: both; margin: 3px 8px;}
                .txt_Article {clear: both; margin: 8px 8px 12px;}
                .txt_Author {float: right;}
                .txt_ArticleAuthor {clear: both; margin: 8px;}
                '''
