#!/usr/bin/env  python
__license__   = 'GPL v3'
__author__    = 'Gabriele Marini, based on Darko Miletic'
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
description   = 'On Line Motor News - 01-05-2010'

'''
http://www.infomotori.it/
'''
from calibre.ebooks.BeautifulSoup import BeautifulSoup
from calibre.web.feeds.news import BasicNewsRecipe

class infomotori(BasicNewsRecipe):
    author         = 'Gabriele Marini'
    title          = u'Infomotori'
    cover          = 'http://www.infomotori.com/content/files/anniversario_01.gif'
    oldest_article        = 31
    max_articles_per_feed = 100
    recursion             = 100
    use_embedded_content  = False

    language       = 'it'
    use_embedded_content  = False
    remove_javascript     = True
    no_stylesheets        = True
    language       = 'it'
    timefmt        = '[%a, %d %b, %Y]'


    def print_version(self, url):
        raw = self.browser.open(url).read()
        soup = BeautifulSoup(raw.decode('utf8', 'replace'))
        print_link = soup.find('a', {'class':'printarticle'})

        '''if print_link is None:

               keep_only_tags     = [  dict(name='div', attrs={'class':['article main-column-article photogallery-column','category-header','article-body']})
                                    ]
               remove_tags        = [ dict(name='div', attrs={'class':['thumbnails-article','infoflash-footer','imushortarticle']}),
                                      dict(name='div', attrs={'id':['linkinviastampa','linkspazioblu','altriarticoli','articoliconcorrenti','articolicorrelati','boxbrand']}),
                                      dict(name='table', attrs={'class':'article-page'})
                                    ]

               remove_tags_after  = [ dict(name='div', attrs={'id':'articlebody'})
                                    ]
               return url
           '''
        return print_link['href']

    feeds          =     [(u'Ultime Novit\xe0', u'http://feeds.infomotori.com/ultimenovita'),
                          (u'Auto: Ultime Novit\xe0 ', u'http://feeds.infomotori.com/autonovita'),
                          (u'Moto: Ultime Novit\xe0 Moto', u'http://feeds.infomotori.com/motonovita'),
                          (u'Notizie Flash', u'http://feeds.infomotori.com/infoflashmotori'),
                          (u'Veicoli Ecologici e Mobilit\xe0 Sostenibile', u'http://feeds.infomotori.com/ecomotori'),
                          (u'4x4 Fuoristrada, Crossover e Suv', u'http://feeds.infomotori.com/fuoristrada'),
                          (u'Shopping Motori', u'http://feeds.infomotori.com/shoppingmotori')
                         ]
