from calibre.web.feeds.news import BasicNewsRecipe


class AdvancedUserRecipe(BasicNewsRecipe):
    title = 'Contropiano'
    oldest_article = 7
    max_articles_per_feed = 25
    language = 'it'
    __author__ = 'michele'

    remove_javascript = True
    no_stylesheets = True
    use_embedded_content = False
    remove_empty_feeds = True

    keep_only_tags = [dict(name='div', attrs={'class': ['category-archive single']}), dict(name='div', attrs={'class': ['content-post']})]

    remove_tags = [
        dict(name='span', attrs={'id': ['postviews']}),
        dict(name='div', attrs={'class': ['social-share']}),
        dict(name='p', attrs={'class': ['firma-redazione']}),
    ]

    remove_tags_after = dict(name='p', attrs={'class': ['firma-redazione']})

    feeds = [
        ('Politica', 'http://contropiano.org/news/politica-news/feed'),
        ('Internazionale', 'http://contropiano.org/news/internazionale-news/feed'),
        ('Aggiornamenti in breve', 'http://contropiano.org/news/aggiornamenti-in-breve/feed'),
        ('Economia', 'http://contropiano.org/news/news-economia/feed'),
        ('Ambiente', 'http://contropiano.org/news/ambiente-news/feed'),
        ('Scienza', 'http://contropiano.org/news/scienza-news/feed'),
        ('Cultura', 'http://contropiano.org/news/cultura-news/feed'),
        ('Locali', 'http://contropiano.org/regionali/feed'),
        ('Lavoro', 'http://contropiano.org/news/lavoro-conflitto-news/feed'),
        ('Malapolizia', 'http://contropiano.org/news/malapolizia-news/feed'),
        ('Interventi', 'http://contropiano.org/interventi/feed'),
        ('Documenti', 'http://contropiano.org/documenti/feed'),
        ('Vignette', 'http://contropiano.org/vignette/feed'),
        ('Altro', 'http://contropiano.org/altro/feed'),
    ]
