__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'

'''
Fetch Anandtech.
'''

from calibre.web.feeds.news import BasicNewsRecipe


class anan(BasicNewsRecipe):
    title = 'Anandtech'
    description = 'comprehensive Hardware Tests'
    __author__ = 'Oliver Niesner, Armin Geller'  # 2014-02-27 AGE: update
    use_embedded_content = False
    language = 'en'
    timefmt = ' [%d %b %Y]'
    oldest_article = 7
    max_articles_per_feed = 40
    no_stylesheets = True
    remove_javascript = True
    encoding = 'utf-8'

    cover_url = 'http://www.anandtech.com/content/images/globals/header_logo.png'
    masthead_url = 'http://www.anandtech.com/content/images/globals/printheader.png'

    keep_only_tags = [
        dict(name='section', attrs={'class': ['main_cont']}),
    ]
    remove_tags = [
        dict(
            name='div',
            attrs={
                'class': [
                    'print',
                    'breadcrumb_area noprint',
                    'fl-rt noprint',
                    'blog_top_right',
                ]
            },
        )
    ]

    feeds = [('Anandtech', 'http://www.anandtech.com/rss/')]

    def print_version(self, url):
        # return url.replace("0Cshow0C", "0Cprint0C") # 2013-09-07 AGE: update
        return url.replace('/show/', '/print/')  # 2014-02-27 AGE: update
