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

from calibre.web.feeds.news import BasicNewsRecipe


class Zerkalo(BasicNewsRecipe):
    title = '\u0417\u0435\u0440\u043A\u0430\u043B\u043E \u043D\u0435\u0434\u0435\u043B\u0438. \u0423\u043A\u0440\u0430\u0438\u043D\u0430'
    __author__ = 'bugmen00t'
    description = '\u041E\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043D\u043D\u043E-\u043F\u043E\u043B\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u043E\u043D\u043D\u043E-\u0430\u043D\u0430\u043B\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u0435\u0436\u0435\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A.'  # noqa
    publisher = '\u00AB\u0417\u0435\u0440\u043A\u0430\u043B\u043E \u043D\u0435\u0434\u0435\u043B\u0438. \u0423\u043A\u0440\u0430\u0438\u043D\u0430\u00BB'
    category = 'newspaper'
    cover_url = u'https://zn.ua/user/img/zn_no_photo_amp.png'
    language = 'ru_UK'
    no_stylesheets = False
    remove_javascript = False
    auto_cleanup = False
    remove_empty_feeds = True
    oldest_article = 7
    max_articles_per_feed = 200

    remove_tags_before = dict(name='h1')

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

    remove_tags = [
        dict(name='span', attrs={'class': 'print print-art-js'}),
        dict(name='div', attrs={'class': 'questionnaire '}),
        dict(name='div', attrs={'class': 'nts-video-wrapper'}),
        dict(name='div', attrs={'class': 'telegram'}),
        dict(name='div', attrs={'class': 'mist_block'}),
        dict(name='div', attrs={'class': 'auth_articles_block'}),
        dict(name='div', attrs={'class': 'special_theme_news_block'}),
        dict(name='div', attrs={'class': 'article_attached acenter'}),
        dict(name='div', attrs={'class': 'article_left'}),
        dict(name='div', attrs={'class': 'top_social_holder'})
    ]

    feeds = [
        (
            '\u041D\u043E\u0432\u043E\u0441\u0442\u0438',
            'https://zn.ua/rus/rss/full.rss'
        ),
        #       ('\u0421\u0442\u0430\u0442\u044C\u0438', 'https://zn.ua/rus/rss/articles.rss')
    ]

    def preprocess_html(self, soup):
        for img in soup.findAll('img', attrs={'data-src': True}):
            img['src'] = img['data-src']
        return soup
