from calibre.web.feeds.news import BasicNewsRecipe


class AdvancedUserRecipe1450864843(BasicNewsRecipe):
    title = 'Tagesanzeiger'
    __author__ = 'noxxx'
    language = 'de'
    oldest_article = 1
    max_articles_per_feed = 8
    no_stylesheets = True
    auto_cleanup = True
    scale_news_images_to_device = True
    compress_news_images = True
    remove_javascript = True
    encoding = 'utf-8'
    remove_empty_feeds = True
    ignore_duplicate_articles = {'title', 'url'}

    feeds = [
        ('Front', 'http://www.tagesanzeiger.ch/rss.html'),
        ('Zurich', 'http://www.tagesanzeiger.ch/zuerich/rss.html'),
        ('Schweiz', 'http://www.tagesanzeiger.ch/schweiz/rss.html'),
        ('International', 'http://www.tagesanzeiger.ch/ausland/rss.html'),
        ('Wirtschaft', 'http://www.tagesanzeiger.ch/wirtschaft/rss.html'),
        ('Sport', 'http://www.tagesanzeiger.ch/sport/rss.html'),
        ('Kultur', 'http://www.tagesanzeiger.ch/kultur/rss.html'),
        ('Leben', 'http://www.tagesanzeiger.ch/leben/rss.html'),
        ('Panorama', 'http://www.tagesanzeiger.ch/panorama/rss.html'),
        ('Digital', 'http://www.tagesanzeiger.ch/digital/rss.html'),
    ]

    keep_only_tags = [dict(name='h1'), dict(name='h3'), dict(name='div', attrs={'id': 'topElement'}), dict(name='div', attrs={'id': 'mainContent'})]

    auto_cleanup_keep = {'//div[@id="article-image"]', '//*[@class="standard"]'}

    conversion_options = {'base_font_size': 12}

    extra_css = '''h1 { font-size: 150%; font-weight: bold; }
                   h2 { font-size: 120%; font-weight: bold; }
                   h3 { font-size: 100%; font-style: italic; }
                   h4, h5, h6 { font-size: 100%; font-style: italic; }'''

    def get_cover_url(self):
        self.cover_url = 'http://newsmail.cleartext.ch/referenz_tagesanzeiger.jpg'
        return getattr(self, 'cover_url', None)
