# -*- coding: utf-8 -*-
__license__ = 'GPL v3'
__copyright__ = '2011 Aurélien Chabot <contact@aurelienchabot.fr>'
'''
20minutes.fr
'''
from calibre.web.feeds.recipes import BasicNewsRecipe


def classes(classes):
    q = frozenset(classes.split(' '))
    return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})


class Minutes(BasicNewsRecipe):
    title = '20 minutes'
    __author__ = 'Aurélien Chabot'
    description = 'Actualités'
    encoding = 'utf-8'
    publisher = '20minutes.fr'
    category = 'Actualités, France, Monde'
    language = 'fr'

    use_embedded_content = False
    timefmt = ' [%d %b %Y]'
    max_articles_per_feed = 15
    no_stylesheets = True
    remove_empty_feeds = True

    keep_only_tags = [
        dict(name='h1'),
        classes('lt-endor-body'),
    ]
    remove_tags = [
        classes('content-related sharebar'),
    ]
    remove_tags_after = dict(id='ob_holder')

    feeds = [
        ('France', 'http://www.20minutes.fr/rss/actu-france.xml'),
        ('International', 'http://www.20minutes.fr/rss/monde.xml'),
        ('Tech/Web', 'http://www.20minutes.fr/rss/hightech.xml'),
        ('Sciences', 'http://www.20minutes.fr/rss/sciences.xml'),
        ('Economie', 'http://www.20minutes.fr/rss/economie.xml'),
        ('Politique', 'http://www.20minutes.fr/rss/politique.xml'),
        ('Médias', 'http://www.20minutes.fr/rss/media.xml'),
        ('Cinema', 'http://www.20minutes.fr/rss/cinema.xml'),
        ('People', 'http://www.20minutes.fr/rss/people.xml'),
        ('Culture', 'http://www.20minutes.fr/rss/culture.xml'),
        ('Sport', 'http://www.20minutes.fr/rss/sport.xml'),
        ('Paris', 'http://www.20minutes.fr/rss/paris.xml'),
        ('Lyon', 'http://www.20minutes.fr/rss/lyon.xml'),
        ('Toulouse', 'http://www.20minutes.fr/rss/toulouse.xml'),
    ]
