#!/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: E501
    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 = '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
