__license__ = 'GPL v3'
__copyright__ = 'Jelle van der Waa <jelle@vdwaa.nl>'

from calibre.web.feeds.news import BasicNewsRecipe


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


class KrebsOnSecurity(BasicNewsRecipe):

    title = u'Krebs on Security'
    publisher = u'Brian Krebs'
    __author__ = 'Jelle van der Waa'
    description = 'In-depth Security news and investigation'
    category = 'security, news'
    cover_url = 'http://krebsonsecurity.com/wp-content/themes/krebsads/krebsads/images/header.jpg'
    oldest_article = 14
    max_articles_per_feed = 100
    remove_javascript = True
    no_stylesheets = True
    use_embedded_content = False
    language = 'en'
    remove_empty_feeds = True
    keep_only_tags = [
        classes('entry-header entry-content entry-meta')
    ]
    remove_attributes = ['width', 'height']
    feeds = [(u'Krebs on security', u'http://feeds.feedburner.com/KrebsOnSecurity')]
