#!/usr/bin/env python
# vim:fileencoding=utf-8

from calibre.web.feeds.news import BasicNewsRecipe


class NovayaGazetaEurope(BasicNewsRecipe):
    title = u'Novaya Gazeta Europe'
    __author__ = 'bugmen00t'
    description = u'English edition of Novaya Gazeta Europe: news, analytics, expert opinions, special reports and investigative journalism.'
    publisher = 'Kirill Martynov'
    category = 'news'
    language = 'en_RU'
    cover_url = 'https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/5dc71e2d-9763-4f05-8f4e-92049fa32af7_513x513.png'
    oldest_article = 15
    max_articles_per_feed = 50
    auto_cleanup = False

    remove_tags_before = dict(name='h1')

    remove_tags_after = dict(
        name='div', attrs={'class': 'ArticleBlocks_wrapperNoAside__11_bu'}
    )

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

    feeds = [(u'News', 'https://novayagazeta.eu/feed/rss/en')]

    def preprocess_html(self, soup):
        for alink in soup.findAll('a'):
            if alink.string is not None:
                tstr = alink.string
                alink.replaceWith(tstr)
        return soup
