from calibre.web.feeds.news import BasicNewsRecipe


class PolitiFactCom(BasicNewsRecipe):
    title = u'Politifact'
    __author__ = u'Michael Heinz'
    oldest_article = 21
    max_articles_per_feed = 100
    language = 'en'

    no_stylesheets = True

    publication_type = 'magazine'
    masthead_url = 'http://static.politifact.com.s3.amazonaws.com/images/politifactdotcom-flag-fff_01.png'
    cover_url = 'http://static.politifact.com.s3.amazonaws.com/images/politifactdotcom-flag-fff_01.png'

    remove_tags = [
        dict(name='div', attrs={'class': 'pfstoryarchive'}),
        dict(name='div', attrs={'class': 'pfhead'}),
        dict(name='div', attrs={'class': 'boxmid'}),
    ]

    keep_only_tags = [dict(name='div', attrs={'class': 'pfcontentleft'})]
    feeds = [
        (u'Articles', u'http://www.politifact.com/feeds/articles/truth-o-meter/'),
        (u'Obamameter', u'http://politifact.com/feeds/updates/'),
        (u'Statements', u'http://www.politifact.com/feeds/statements/truth-o-meter/')
    ]

    def get_browser(self):
        br = BasicNewsRecipe.get_browser(self)
        br.set_handle_gzip(True)
        return br
