#!/usr/bin/env  python
__license__     = 'GPL v3'
__author__      = 'Lorenzo Vigentini, Gabriele Marini'
__copyright__   = '2009, Lorenzo Vigentini <l.vigentini at gmail.com>'
__version__     = 'v1.02'
__date__        = '10, January 2010'
__description__ = 'Italian weekly magazine'

'''espresso.repubblica.it'''

from calibre.web.feeds.news import BasicNewsRecipe

class Espresso(BasicNewsRecipe):
    __author__     = 'Lorenzo Vigentini, Gabriele Marini'
    description    = 'Italian weekly magazine'

    cover_url      = 'http://espresso.repubblica.it/images/logo_espresso.gif'
    title          = 'L\'Espresso '
    publisher      = 'Gruppo editoriale L\'Espresso'
    category       = 'News, politics, culture, economy, general interest'

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

    oldest_article        = 16
    max_articles_per_feed = 100
    use_embedded_content  = False
    recursion             = 10

    remove_javascript     = True
    no_stylesheets = True


    feeds          = [
                       (u'Homepage', u'http://kpm.data.kataweb.it/kpm3eolx/rss/home'),
                       (u'Local', u'http://kpm.data.kataweb.it/kpm3eolx/rss/local'),
                       (u'Style & Design', u'http://kpm.data.kataweb.it/kpm3eolx/rss/style_design'),
                       (u'Opinioni', u'http://kpm.data.kataweb.it/kpm3eolx/rss/opinioni'),
                       (u'Rubriche', u'http://kpm.data.kataweb.it/kpm3eolx/rss/rubriche'),
                       (u'Limes', u'http://temi.repubblica.it/limes/feed/'),
                       (u'Chiesa: HomePage', u'http://data.kataweb.it/rss/chiesa/homepage/it'),
                       (u'Chiesa: Speciali e Focus', u'http://data.kataweb.it/rss/chiesa/speciali_e_focus/it')
                    ]


    def print_version(self,url):
        print url[7:25]
        if url[7:25] == 'temi.repubblica.it':
          return url + '/?printpage=undefined'
        elif url[7:25] == 'www.chiesa.espress':
          return url
        return url + '/&print=true'


    keep_only_tags     = [
                            dict(name='div', attrs={'class':['testo','copertina','occhiello','firma','didascalia','content-second-right','detail-articles','titolo-local','generic-articles']}),
                            dict(name='div', attrs={'class':['generic-articles','summary','detail-articles']}),
                            dict(name='div', attrs={'id':['content-second-right','content2']})
                          ]

    remove_tags        = [
                            dict(name='div',attrs={'class':['servizi','aggiungi','label-web','bottom-mobile','box-abbonamenti','box-cerca','big','little','stampaweb']}),
                            dict(name='div',attrs={'id':['topheader','header','navigation-new','navigation','content-second-left','menutext']}),
                            dict(name='ul',attrs={'id':'user-utility'}),
                            dict(name=['script','noscript','iframe'])
                         ]
#    extra_css = '''
#                h1 {font-family:Times New Roman,"Trebuchet MS",Arial,Helvetica,sans-serif; font-size:24px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:18px;}
#                h2 {font-family:Times New Roman, "Trebuchet MS",Arial,Helvetica,sans-serif; font-size:18px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:16px; }
#                h3 {color:#333333;font-family:Times New Roman, "Trebuchet MS",Arial,Helvetica,sans-serif; font-size:16px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:14px;}
#                h4 {color:#333333; font-family:Times New Roman, "Trebuchet MS",Arial,Helvetica,sans-serif;font-size:16px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:14px; }
#                h5 {color:#333333; font-family:Times New Roman, "Trebuchet MS",Arial,Helvetica,sans-serif; font-size:12px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:14px; text-transform:uppercase;}
#                .firma {color:#333333;font-family:Times New Roman, "Trebuchet MS",Arial,Helvetica,sans-serif;font-size:12px; font-size-adjust:none; font-stretch:normal; font-style:italic; font-variant:normal; font-weight:bold; line-height:15px; text-decoration:none;}
#                .testo {font-family:Times New Roman, "Trebuchet MS",Arial,Helvetica,sans-serif; font-size:10px;}
#                '''

